You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
625 lines
28 KiB
C#
625 lines
28 KiB
C#
using System;
|
|
using System.Data;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using DSWeb.MvcShipping.Models.SysBillType;
|
|
using DSWeb.MvcShipping.Models.MsSysBillNoSet;
|
|
using Microsoft.Practices.EnterpriseLibrary.Data;
|
|
using DSWeb.Areas.CommMng.Models;
|
|
using HcUtility.Comm;
|
|
using DSWeb.TruckMng.Comm.Cookie;
|
|
using DSWeb.EntityDA;
|
|
using System.Transactions;
|
|
|
|
namespace DSWeb.MvcShipping.DAL.MsSysBillNoSet
|
|
{
|
|
public class MsSysBillNoSetDAL
|
|
{
|
|
#region BillNoSet
|
|
|
|
static public List<SysBillNoSet> GetDataList(string strCondition, string companyid, string sort = null,string dbname="")
|
|
{
|
|
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT ");
|
|
strSql.Append("GID,OPLBNAME,RULEBLNO,RULEDATETYPE,BILLTYPE,COMPANYID,ISEDIT,ISAUTO,ISOPADD,CUSTOMHEAD");
|
|
strSql.Append(",(select BillName from tSysBillType where BillCode=sys_billno_set.BILLTYPE) BILLTYPEREF");
|
|
strSql.Append(" from sys_billno_set where COMPANYID='" + companyid + "'");
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strSql.Append(" and " + strCondition);
|
|
}
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
{
|
|
strSql.Append(" order by " + sortstring);
|
|
}
|
|
else {
|
|
strSql.Append(" order by OPLBNAME");
|
|
|
|
}
|
|
return SetData(strSql,dbname);
|
|
}
|
|
|
|
static public SysBillNoSet GetData(string condition, string companyid,string dbname="")
|
|
{
|
|
SysBillNoSet data = null;
|
|
var list = GetDataList(condition,companyid,null,dbname);
|
|
if (list.Count > 0)
|
|
data = list[0];
|
|
|
|
if (data == null)
|
|
{
|
|
data = new SysBillNoSet();
|
|
}
|
|
|
|
return data;
|
|
}
|
|
|
|
/*
|
|
public static string GetNewNo(string bltype, string ruleblno, string BILLTYPE, string companyid, string etd, string accdate=null)
|
|
{
|
|
if (etd.Length <= 7) return "";
|
|
if (accdate == null )
|
|
{
|
|
accdate = etd.Substring(0, 7);
|
|
}
|
|
var billnoset = MsSysBillNoSetDAL.GetData("OPLBNAME='" + bltype + "' AND RULEBLNO='" + ruleblno + "' AND BILLTYPE='" + BILLTYPE + "'", companyid);
|
|
if (billnoset.BILLTYPE != "")
|
|
{
|
|
var custno = MsSysBillNoSetDAL.GetBillNo(billnoset, etd, accdate);
|
|
return custno;
|
|
}
|
|
else
|
|
{
|
|
return "";
|
|
}
|
|
}
|
|
*/
|
|
|
|
public static string GetNewNo(string bltype, string BILLTYPE, string companyid, string etd, string accdate = null)
|
|
{
|
|
if (etd.Length <= 7) return "";
|
|
if (accdate == null)
|
|
{
|
|
accdate = etd.Substring(0, 7);
|
|
}
|
|
var billnoset = MsSysBillNoSetDAL.GetData("OPLBNAME='" + bltype + "' AND (RULEBLNO='" + BILLTYPE + "' or BILLTYPE='"+ BILLTYPE + "')", companyid);
|
|
if (billnoset.BILLTYPE != "")
|
|
{
|
|
var custno = MsSysBillNoSetDAL.GetBillNo(billnoset, etd, accdate);
|
|
return custno;
|
|
}
|
|
else
|
|
{
|
|
return "";
|
|
}
|
|
}
|
|
|
|
private static List<SysBillNoSet> SetData(StringBuilder strSql,string dbname="")
|
|
{
|
|
var headList = new List<SysBillNoSet>();
|
|
|
|
Database db = string.IsNullOrWhiteSpace(dbname)? DatabaseFactory.CreateDatabase(): DatabaseFactory.CreateDatabase(dbname);
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
SysBillNoSet data = new SysBillNoSet();
|
|
#region Set DB data to Object
|
|
data.GID = Convert.ToString(reader["GID"]);
|
|
data.OPLBNAME = Convert.ToString(reader["OPLBNAME"]);
|
|
data.RULEBLNO = Convert.ToString(reader["RULEBLNO"]);
|
|
data.RULEDATETYPE = Convert.ToString(reader["RULEDATETYPE"]);
|
|
data.COMPANYID = Convert.ToString(reader["COMPANYID"]);
|
|
data.BILLTYPE = Convert.ToString(reader["BILLTYPE"]);
|
|
data.BILLTYPEREF = Convert.ToString(reader["BILLTYPEREF"]);
|
|
data.ISEDIT = Convert.ToString(reader["ISEDIT"]);
|
|
data.ISAUTO = Convert.ToString(reader["ISAUTO"]);
|
|
data.CUSTOMHEAD = Convert.ToString(reader["CUSTOMHEAD"]);
|
|
data.ISOPADD = Convert.ToString(reader["ISOPADD"]);
|
|
#endregion
|
|
headList.Add(data);
|
|
}
|
|
reader.Close();
|
|
}
|
|
return headList;
|
|
}
|
|
#endregion
|
|
|
|
public static DBResult SaveBillSetDetail(List<SysBillNoSet> bodyList, string companyid)
|
|
{
|
|
var result = new DBResult();
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
|
|
try
|
|
{
|
|
|
|
var cmdInsert =
|
|
db.GetSqlStringCommand(
|
|
@"insert into sys_billno_set (GID,OPLBNAME,RULEBLNO,RULEDATETYPE,BILLTYPE,COMPANYID,ISEDIT,ISAUTO,CUSTOMHEAD,ISOPADD)
|
|
values (@GID,@OPLBNAME,@RULEBLNO,@RULEDATETYPE,@BILLTYPE,@COMPANYID,@ISEDIT,@ISAUTO,@CUSTOMHEAD,@ISOPADD) ");
|
|
|
|
var cmdUpdate =
|
|
db.GetSqlStringCommand(
|
|
@"update sys_billno_set set OPLBNAME=@OPLBNAME,RULEBLNO=@RULEBLNO,RULEDATETYPE=@RULEDATETYPE,BILLTYPE=@BILLTYPE,COMPANYID=@COMPANYID,ISEDIT=@ISEDIT,ISAUTO=@ISAUTO,CUSTOMHEAD=@CUSTOMHEAD,ISOPADD=@ISOPADD where GID=@GID ");
|
|
|
|
if (bodyList != null)
|
|
{
|
|
foreach (var enumValue in bodyList)
|
|
{
|
|
|
|
if (enumValue.GID == "*" || enumValue.GID == "")
|
|
{
|
|
cmdInsert.Parameters.Clear();
|
|
db.AddInParameter(cmdInsert, "@GID", DbType.String, Guid.NewGuid().ToString());
|
|
db.AddInParameter(cmdInsert, "@OPLBNAME", DbType.String, enumValue.OPLBNAME);
|
|
db.AddInParameter(cmdInsert, "@RULEBLNO", DbType.String, enumValue.RULEBLNO);
|
|
db.AddInParameter(cmdInsert, "@RULEDATETYPE", DbType.String, enumValue.RULEDATETYPE);
|
|
db.AddInParameter(cmdInsert, "@BILLTYPE", DbType.String, enumValue.BILLTYPE);
|
|
db.AddInParameter(cmdInsert, "@ISEDIT", DbType.String, enumValue.ISEDIT);
|
|
db.AddInParameter(cmdInsert, "@ISAUTO", DbType.String, enumValue.ISAUTO);
|
|
db.AddInParameter(cmdInsert, "@CUSTOMHEAD", DbType.String, enumValue.CUSTOMHEAD);
|
|
db.AddInParameter(cmdInsert, "@ISOPADD", DbType.String, enumValue.ISOPADD);
|
|
db.AddInParameter(cmdInsert, "@COMPANYID", DbType.String, companyid);
|
|
db.ExecuteNonQuery(cmdInsert, tran);
|
|
}
|
|
else
|
|
{
|
|
|
|
cmdUpdate.Parameters.Clear();
|
|
db.AddInParameter(cmdUpdate, "@GID", DbType.String, enumValue.GID);
|
|
|
|
db.AddInParameter(cmdUpdate, "@OPLBNAME", DbType.String, enumValue.OPLBNAME);
|
|
db.AddInParameter(cmdUpdate, "@RULEBLNO", DbType.String, enumValue.RULEBLNO);
|
|
db.AddInParameter(cmdUpdate, "@RULEDATETYPE", DbType.String, enumValue.RULEDATETYPE);
|
|
db.AddInParameter(cmdUpdate, "@BILLTYPE", DbType.String, enumValue.BILLTYPE);
|
|
db.AddInParameter(cmdUpdate, "@ISEDIT", DbType.String, enumValue.ISEDIT);
|
|
db.AddInParameter(cmdUpdate, "@ISAUTO", DbType.String, enumValue.ISAUTO);
|
|
db.AddInParameter(cmdUpdate, "@CUSTOMHEAD", DbType.String, enumValue.CUSTOMHEAD);
|
|
db.AddInParameter(cmdUpdate, "@ISOPADD", DbType.String, enumValue.ISOPADD);
|
|
|
|
db.AddInParameter(cmdUpdate, "@COMPANYID", DbType.String, enumValue.COMPANYID);
|
|
db.ExecuteNonQuery(cmdUpdate, tran);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
tran.Commit();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "保存出现错误,请重试或联系系统管理员";
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
result.Success = true;
|
|
result.Message = "保存成功" + result.Message;
|
|
|
|
return result;
|
|
}
|
|
|
|
|
|
#region BillType
|
|
|
|
static public List<BillType> GetBillTypeDataList(string strCondition, string companyid, string sort = null)
|
|
{
|
|
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT ");
|
|
strSql.Append("GID,BillCode,BillName,BillGrp,IsRule,NoLength,IsPrefix,PrefixLen,PrefixNo,[IsDate],DateFmt,");
|
|
strSql.Append(" SerialLen,YearNo,MonthNo,DayNo,MaxSerial,BillHeadTbl,IsOrgPrefix,IsEmpPrefix from tSysBillType ");
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strSql.Append(" and " + strCondition);
|
|
}
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
{
|
|
strSql.Append(" order by " + sortstring);
|
|
}
|
|
else
|
|
{
|
|
strSql.Append(" order by BillCode");
|
|
|
|
}
|
|
return SetBillTypeData(strSql);
|
|
}
|
|
|
|
static public BillType GetBillTypeData(string condition, string companyid)
|
|
{
|
|
BillType data = null;
|
|
var list = GetBillTypeDataList(condition, companyid);
|
|
if (list.Count > 0)
|
|
data = list[0];
|
|
|
|
if (data == null)
|
|
{
|
|
data = new BillType();
|
|
}
|
|
|
|
return data;
|
|
}
|
|
|
|
|
|
private static List<BillType> SetBillTypeData(StringBuilder strSql)
|
|
{
|
|
var headList = new List<BillType>();
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
BillType data = new BillType();
|
|
#region Set DB data to Object
|
|
data.GID = Convert.ToString(reader["GID"]);
|
|
data.BillCode = Convert.ToString(reader["BillCode"]);
|
|
data.BillName = Convert.ToString(reader["BillName"]);
|
|
data.BillGrp = Convert.ToString(reader["BillGrp"]);
|
|
data.IsRule = Convert.ToString(reader["IsRule"]);
|
|
data.NoLength = Convert.ToInt32(reader["NoLength"]);
|
|
data.IsPrefix = Convert.ToString(reader["IsPrefix"]);
|
|
data.PrefixLen = Convert.ToInt16(reader["PrefixLen"]);
|
|
data.PrefixNo = Convert.ToString(reader["PrefixNo"]);
|
|
data.IsDate = Convert.ToString(reader["IsDate"]);
|
|
data.DateFmt = Convert.ToString(reader["DateFmt"]);
|
|
data.SerialLen = Convert.ToInt16(reader["SerialLen"]);
|
|
data.YearNo = Convert.ToString(reader["YearNo"]);
|
|
data.MonthNo = Convert.ToString(reader["MonthNo"]);
|
|
data.DayNo = Convert.ToString(reader["DayNo"]);
|
|
data.MaxSerial = Convert.ToInt32(reader["MaxSerial"]);
|
|
data.BillHeadTbl = Convert.ToString(reader["BillHeadTbl"]);
|
|
data.IsOrgPrefix = Convert.ToString(reader["IsOrgPrefix"]);
|
|
data.IsEmpPrefix = Convert.ToString(reader["IsEmpPrefix"]);
|
|
|
|
#endregion
|
|
headList.Add(data);
|
|
}
|
|
reader.Close();
|
|
}
|
|
return headList;
|
|
}
|
|
|
|
public static DBResult SaveBillTypeDetail(List<BillType> bodyList, string companyid)
|
|
{
|
|
var result = new DBResult();
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
|
|
try
|
|
{
|
|
|
|
var cmdInsert =
|
|
db.GetSqlStringCommand(
|
|
@"insert into tSysBillType (GID,BillCode,BillName,BillGrp,IsRule,NoLength,IsPrefix,PrefixLen,PrefixNo,[IsDate],DateFmt,SerialLen,YearNo,MonthNo,DayNo,MaxSerial,BillHeadTbl,IsOrgPrefix,IsEmpPrefix)
|
|
values (@GID,@BillCode,@BillName,@BillGrp,@IsRule,@NoLength,@IsPrefix,@PrefixLen,@PrefixNo,@IsDate,@DateFmt,@SerialLen,@YearNo,@MonthNo,@DayNo,@MaxSerial,@BillHeadTbl,@IsOrgPrefix,@IsEmpPrefix) ");
|
|
|
|
var cmdUpdate =
|
|
db.GetSqlStringCommand(
|
|
@"update tSysBillType set BillCode=@BillCode,BillName=@BillName,BillGrp=@BillGrp,IsRule=@IsRule,NoLength=@NoLength,IsPrefix=@IsPrefix,PrefixLen=@PrefixLen,PrefixNo=@PrefixNo
|
|
,IsDate=@IsDate,DateFmt=@DateFmt,SerialLen=@SerialLen,YearNo=@YearNo,MonthNo=@MonthNo,DayNo=@DayNo,MaxSerial=@MaxSerial,BillHeadTbl=@BillHeadTbl,
|
|
IsOrgPrefix=@IsOrgPrefix,IsEmpPrefix=@IsEmpPrefix where GID=@GID ");
|
|
|
|
if (bodyList != null)
|
|
{
|
|
foreach (var enumValue in bodyList)
|
|
{
|
|
|
|
if (enumValue.GID == "*" || enumValue.GID == "")
|
|
{
|
|
cmdInsert.Parameters.Clear();
|
|
db.AddInParameter(cmdInsert, "@GID", DbType.String, Guid.NewGuid().ToString());
|
|
db.AddInParameter(cmdInsert, "@BillCode", DbType.String, enumValue.BillCode);
|
|
db.AddInParameter(cmdInsert, "@BillName", DbType.String, enumValue.BillName);
|
|
db.AddInParameter(cmdInsert, "@BillGrp", DbType.String, enumValue.BillGrp);
|
|
db.AddInParameter(cmdInsert, "@IsRule", DbType.String, enumValue.IsRule);
|
|
db.AddInParameter(cmdInsert, "@NoLength", DbType.Int16, enumValue.NoLength);
|
|
db.AddInParameter(cmdInsert, "@IsPrefix", DbType.String, enumValue.IsPrefix);
|
|
db.AddInParameter(cmdInsert, "@PrefixLen", DbType.Int16, enumValue.PrefixLen);
|
|
db.AddInParameter(cmdInsert, "@PrefixNo", DbType.String, enumValue.PrefixNo);
|
|
db.AddInParameter(cmdInsert, "@IsDate", DbType.String, enumValue.IsDate);
|
|
db.AddInParameter(cmdInsert, "@DateFmt", DbType.String, enumValue.DateFmt);
|
|
db.AddInParameter(cmdInsert, "@SerialLen", DbType.Int16, enumValue.SerialLen);
|
|
db.AddInParameter(cmdInsert, "@YearNo", DbType.String, enumValue.YearNo);
|
|
db.AddInParameter(cmdInsert, "@MonthNo", DbType.String, enumValue.MonthNo);
|
|
db.AddInParameter(cmdInsert, "@DayNo", DbType.String, enumValue.DayNo);
|
|
db.AddInParameter(cmdInsert, "@MaxSerial", DbType.Int16, enumValue.MaxSerial);
|
|
db.AddInParameter(cmdInsert, "@BillHeadTbl", DbType.String, enumValue.BillHeadTbl);
|
|
db.AddInParameter(cmdInsert, "@IsOrgPrefix", DbType.String, enumValue.IsOrgPrefix);
|
|
db.AddInParameter(cmdInsert, "@IsEmpPrefix", DbType.String, enumValue.IsEmpPrefix);
|
|
db.ExecuteNonQuery(cmdInsert, tran);
|
|
}
|
|
else
|
|
{
|
|
|
|
cmdUpdate.Parameters.Clear();
|
|
db.AddInParameter(cmdUpdate, "@GID", DbType.String, enumValue.GID);
|
|
db.AddInParameter(cmdUpdate, "@BillCode", DbType.String, enumValue.BillCode);
|
|
db.AddInParameter(cmdUpdate, "@BillName", DbType.String, enumValue.BillName);
|
|
db.AddInParameter(cmdUpdate, "@BillGrp", DbType.String, enumValue.BillGrp);
|
|
db.AddInParameter(cmdUpdate, "@IsRule", DbType.String, enumValue.IsRule);
|
|
db.AddInParameter(cmdUpdate, "@NoLength", DbType.Int16, enumValue.NoLength);
|
|
db.AddInParameter(cmdUpdate, "@IsPrefix", DbType.String, enumValue.IsPrefix);
|
|
db.AddInParameter(cmdUpdate, "@PrefixLen", DbType.Int16, enumValue.PrefixLen);
|
|
db.AddInParameter(cmdUpdate, "@PrefixNo", DbType.String, enumValue.PrefixNo);
|
|
db.AddInParameter(cmdUpdate, "@IsDate", DbType.String, enumValue.IsDate);
|
|
db.AddInParameter(cmdUpdate, "@DateFmt", DbType.String, enumValue.DateFmt);
|
|
db.AddInParameter(cmdUpdate, "@SerialLen", DbType.Int16, enumValue.SerialLen);
|
|
db.AddInParameter(cmdUpdate, "@YearNo", DbType.String, enumValue.YearNo);
|
|
db.AddInParameter(cmdUpdate, "@MonthNo", DbType.String, enumValue.MonthNo);
|
|
db.AddInParameter(cmdUpdate, "@DayNo", DbType.String, enumValue.DayNo);
|
|
db.AddInParameter(cmdUpdate, "@MaxSerial", DbType.Int16, enumValue.MaxSerial);
|
|
db.AddInParameter(cmdUpdate, "@BillHeadTbl", DbType.String, enumValue.BillHeadTbl);
|
|
db.AddInParameter(cmdUpdate, "@IsOrgPrefix", DbType.String, enumValue.IsOrgPrefix);
|
|
db.AddInParameter(cmdUpdate, "@IsEmpPrefix", DbType.String, enumValue.IsEmpPrefix);
|
|
db.ExecuteNonQuery(cmdUpdate, tran);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
tran.Commit();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "保存出现错误,请重试或联系系统管理员";
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
result.Success = true;
|
|
result.Message = "保存成功" + result.Message;
|
|
|
|
return result;
|
|
}
|
|
|
|
static public string GetUserCode(string username,string dbname="")
|
|
{
|
|
string EDICODE = "";
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("select CODENAME from [user] where SHOWNAME='" + username + "'");
|
|
Database db = string.IsNullOrWhiteSpace(dbname)? DatabaseFactory.CreateDatabase(): DatabaseFactory.CreateDatabase(dbname);
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
EDICODE = Convert.ToString(reader["CODENAME"]);
|
|
}
|
|
reader.Close();
|
|
}
|
|
return EDICODE;
|
|
|
|
}
|
|
static public string GetCorpCode(string Corpid,string dbname="")
|
|
{
|
|
string EDICODE = "";
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("select CODENAME from [company] where GID='" + Corpid + "'");
|
|
Database db = string.IsNullOrWhiteSpace(dbname) ? DatabaseFactory.CreateDatabase() : DatabaseFactory.CreateDatabase(dbname);
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
EDICODE = Convert.ToString(reader["CODENAME"]);
|
|
}
|
|
reader.Close();
|
|
}
|
|
return EDICODE;
|
|
|
|
}
|
|
|
|
public static string GetBillNo(SysBillNoSet billType, string bsdate="",string accdate="",string dbname="",string opname="",string corpid="", string bshead = "")
|
|
{
|
|
var cookies = new Cookies();
|
|
var orgCode = "";
|
|
var UserCode = "";
|
|
Database db = string.IsNullOrWhiteSpace(dbname)? DatabaseFactory.CreateDatabase(): DatabaseFactory.CreateDatabase(dbname);
|
|
//if (dbname != "") db = DatabaseFactory.CreateDatabase(dbname);
|
|
if (opname != "")
|
|
{
|
|
UserCode = GetUserCode(opname,dbname);
|
|
}
|
|
else {
|
|
UserCode = cookies.getCookie(CookieConstant.UserCode);//登录组织
|
|
}
|
|
if (!string.IsNullOrEmpty(corpid))
|
|
{
|
|
orgCode = GetCorpCode(corpid,dbname);
|
|
}
|
|
else {
|
|
orgCode = cookies.getCookie(CookieConstant.OrgCode);//登录组织
|
|
}
|
|
|
|
|
|
|
|
|
|
var cmd = db.GetStoredProcCommand("sSysGetBillNo_new");
|
|
db.AddInParameter(cmd, "@ps_BillType", DbType.String, billType.BILLTYPE);
|
|
db.AddInParameter(cmd, "@ps_OrgCode", DbType.String, orgCode);
|
|
db.AddInParameter(cmd, "@ps_EmpCode", DbType.String, UserCode);
|
|
db.AddInParameter(cmd, "@ps_bshead", DbType.String, bshead);
|
|
if (billType.RULEDATETYPE == "业务日期")
|
|
{
|
|
if (string.IsNullOrEmpty(bsdate)) bsdate = DateTime.Now.ToString("yyyy-MM-dd");
|
|
|
|
db.AddInParameter(cmd, "@ps_Date", DbType.String, bsdate);
|
|
}
|
|
else if (billType.RULEDATETYPE == "会计期间" && accdate.Length == 7)
|
|
db.AddInParameter(cmd, "@ps_Date", DbType.String, accdate + "-01");
|
|
else
|
|
db.AddInParameter(cmd, "@ps_Date", DbType.String, "");
|
|
db.AddOutParameter(cmd, "@ps_BillNo", DbType.String, 20);
|
|
db.AddInParameter(cmd, "@ps_RefBillNo", DbType.String, null);
|
|
db.ExecuteNonQuery(cmd);
|
|
return Convert.ToString(db.GetParameterValue(cmd, "@ps_BillNo"));
|
|
}
|
|
|
|
public static string GetBillNoHblno(SysBillNoSet billType, string bsdate, string accdate, string bshead = "")
|
|
{
|
|
var cookies = new Cookies();
|
|
var orgCode = cookies.getCookie(CookieConstant.OrgCode);//登录组织
|
|
var UserCode = cookies.getCookie(CookieConstant.UserCode);//登录组织
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
if (bshead != "") {
|
|
orgCode = "";
|
|
UserCode = "";
|
|
}
|
|
var cmd = db.GetStoredProcCommand("sSysGetBillNo_hblno");
|
|
db.AddInParameter(cmd, "@ps_BillType", DbType.String, billType.BILLTYPE);
|
|
db.AddInParameter(cmd, "@ps_OrgCode", DbType.String, orgCode);
|
|
db.AddInParameter(cmd, "@ps_EmpCode", DbType.String, UserCode);
|
|
db.AddInParameter(cmd, "@ps_bshead", DbType.String, bshead);
|
|
if (billType.RULEDATETYPE == "业务日期")
|
|
db.AddInParameter(cmd, "@ps_Date", DbType.String, bsdate);
|
|
else if (billType.RULEDATETYPE == "会计期间")
|
|
db.AddInParameter(cmd, "@ps_Date", DbType.String, accdate + "-01");
|
|
else
|
|
db.AddInParameter(cmd, "@ps_Date", DbType.String, "");
|
|
db.AddOutParameter(cmd, "@ps_BillNo", DbType.String, 20);
|
|
db.AddInParameter(cmd, "@ps_RefBillNo", DbType.String, null);
|
|
db.ExecuteNonQuery(cmd);
|
|
return Convert.ToString(db.GetParameterValue(cmd, "@ps_BillNo"));
|
|
}
|
|
|
|
|
|
public static string GetTrayNo()
|
|
{
|
|
string trayNO = "";
|
|
string strSql = "exec Proc_EIP_OrderNo '2001' ";
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
|
|
while (reader.Read())
|
|
{
|
|
trayNO = reader["result"].ToString();
|
|
|
|
break;
|
|
}
|
|
|
|
reader.Close();
|
|
}
|
|
|
|
|
|
return trayNO;
|
|
|
|
}
|
|
|
|
public static string GetFenCustNo(string masterbsno,string tblname)
|
|
{
|
|
var strnum = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
var billno = "";
|
|
var strnumno ="";
|
|
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
|
|
string mcustno = T_ALL_DA.GetStrSQL("custno", "select top 1 custno from " + tblname + " where bsno='" + masterbsno + "' ");
|
|
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("select custno from " + tblname + " where bsno<>'" + masterbsno + "' and MASTERNO='" + masterbsno + "' order by CUSTNO");
|
|
var i = 0;
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
var evData = Convert.ToString(reader["custno"]);
|
|
var strnumno1 = evData.Substring(evData.Length - 1, 1);
|
|
var strnumno2=strnum.Substring(i, 1);
|
|
if (strnumno1 != strnumno2) strnumno = strnumno2;
|
|
i = i + 1;
|
|
}
|
|
reader.Close();
|
|
}
|
|
|
|
if (strnumno == "") strnumno = strnum.Substring(i, 1);
|
|
billno = mcustno + strnumno;
|
|
|
|
|
|
return billno;
|
|
|
|
}
|
|
|
|
|
|
public static DBResult DeleteBsNo(string BSNO,string dbname="")
|
|
{
|
|
var result = new DBResult();
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
if (dbname != "") db = DatabaseFactory.CreateDatabase(dbname);
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
|
|
try
|
|
{
|
|
|
|
|
|
var cmdUpdate =
|
|
db.GetSqlStringCommand(
|
|
@"update sys_no set ISUSE=1 WHERE BSNO=@BSNO ");
|
|
|
|
|
|
cmdUpdate.Parameters.Clear();
|
|
db.AddInParameter(cmdUpdate, "@BSNO", DbType.String,BSNO);
|
|
|
|
db.ExecuteNonQuery(cmdUpdate, tran);
|
|
|
|
|
|
tran.Commit();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "保存出现错误,请重试或联系系统管理员";
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
result.Success = true;
|
|
result.Message = "保存成功" + result.Message;
|
|
|
|
return result;
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 参照部分
|
|
|
|
#endregion
|
|
}
|
|
}
|