|
|
|
|
using System;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Configuration;
|
|
|
|
|
using System.Web;
|
|
|
|
|
using System.Web.Security;
|
|
|
|
|
using System.Web.UI;
|
|
|
|
|
using System.Web.UI.HtmlControls;
|
|
|
|
|
using System.Web.UI.WebControls;
|
|
|
|
|
using System.Web.UI.WebControls.WebParts;
|
|
|
|
|
using DSWeb.DataAccess;
|
|
|
|
|
using DSWeb.Models;
|
|
|
|
|
using System.Data.SqlClient;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
namespace DSWeb.EntityDA
|
|
|
|
|
{
|
|
|
|
|
public class CodeRuleDA
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
private const string SQL_SELECT_INFO = "select GID,RULENAME,RULECONTENT,RULEDATE,RULEYEAR,RULENOLENGTH,ISSTARTUSING,ISALLOWEDITS,ISCLEAREDINEARLY,ISCOMPANY,ISDEPT,CREATEUSER,CREATETIME,MODIFIEDUSER,MODIFIEDTIME,RULETYPE from code_rule where GID=@GID";
|
|
|
|
|
|
|
|
|
|
public CodeRuleDA()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 根据GID获取信息
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据GID获取信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="strRoleGID"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public CodeRuleEntity GetID(string strGID)
|
|
|
|
|
{
|
|
|
|
|
//初始化返回变量
|
|
|
|
|
CodeRuleEntity CodeRuleEntity = null;
|
|
|
|
|
//初始化参数并赋值
|
|
|
|
|
SqlParameter parm = new SqlParameter("@GID", SqlDbType.VarChar, 36);
|
|
|
|
|
parm.Value = strGID;
|
|
|
|
|
|
|
|
|
|
using (SqlDataReader sqlRead = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SQL_SELECT_INFO, parm))
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
CodeRuleEntity = new CodeRuleEntity();
|
|
|
|
|
//读取字段值
|
|
|
|
|
while (sqlRead.Read())
|
|
|
|
|
{
|
|
|
|
|
if (!sqlRead.IsDBNull(0)) { CodeRuleEntity.GID = sqlRead.GetString(0); }// 惟一编号
|
|
|
|
|
if (!sqlRead.IsDBNull(1)) { CodeRuleEntity.RULENAME = sqlRead.GetString(1); }//
|
|
|
|
|
if (!sqlRead.IsDBNull(2)) { CodeRuleEntity.RULECONTENT = sqlRead.GetString(2); }//
|
|
|
|
|
if (!sqlRead.IsDBNull(3)) { CodeRuleEntity.RULEDATE = sqlRead.GetString(3); }//
|
|
|
|
|
if (!sqlRead.IsDBNull(4)) { CodeRuleEntity.RULEYEAR = sqlRead.GetString(4); }//
|
|
|
|
|
if (!sqlRead.IsDBNull(5)) { CodeRuleEntity.RULENOLENGTH = sqlRead.GetString(5); }//
|
|
|
|
|
if (!sqlRead.IsDBNull(6)) { CodeRuleEntity.ISSTARTUSING = sqlRead.GetBoolean(6); }//
|
|
|
|
|
if (!sqlRead.IsDBNull(7)) { CodeRuleEntity.ISALLOWEDITS = sqlRead.GetBoolean(7); }//
|
|
|
|
|
if (!sqlRead.IsDBNull(8)) { CodeRuleEntity.ISCLEAREDINEARLY = sqlRead.GetBoolean(8); }//
|
|
|
|
|
if (!sqlRead.IsDBNull(9)) { CodeRuleEntity.ISCOMPANY = sqlRead.GetBoolean(9); }//
|
|
|
|
|
if (!sqlRead.IsDBNull(10)) { CodeRuleEntity.ISDEPT = sqlRead.GetBoolean(10); }//
|
|
|
|
|
if (!sqlRead.IsDBNull(11)) { CodeRuleEntity.CREATEUSER = sqlRead.GetString(11); }//
|
|
|
|
|
if (!sqlRead.IsDBNull(12)) { CodeRuleEntity.CREATETIME = sqlRead.GetDateTime(12); }//
|
|
|
|
|
if (!sqlRead.IsDBNull(13)) { CodeRuleEntity.MODIFIEDUSER = sqlRead.GetString(13); }//
|
|
|
|
|
if (!sqlRead.IsDBNull(14)) { CodeRuleEntity.MODIFIEDTIME = sqlRead.GetDateTime(14); }//
|
|
|
|
|
if (!sqlRead.IsDBNull(15)) { CodeRuleEntity.RULETYPE = sqlRead.GetInt32(15); }//
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception exceError)
|
|
|
|
|
{
|
|
|
|
|
//抛出异常
|
|
|
|
|
throw exceError;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return CodeRuleEntity;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
#region 提取规则编号
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 提取规则编号
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="strRULENAME">规则项目名称</param>
|
|
|
|
|
/// <param name="strfield">需要加规则的字段</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
//public String getCodeRule(string strRULENAME, string strfield, int RULETYPE)
|
|
|
|
|
//{
|
|
|
|
|
// //调用编码规则
|
|
|
|
|
// string strRULEYEAR = "";
|
|
|
|
|
// string strRULECONTENT = "";
|
|
|
|
|
// string strCODENAME = "";
|
|
|
|
|
// string strDEPTNO = "";
|
|
|
|
|
// string strRULENOLENGTH = "";
|
|
|
|
|
// int iRULENOLENGTH = 0;
|
|
|
|
|
// int inum = 0;
|
|
|
|
|
// string strCONTENT = "";
|
|
|
|
|
// string strSql;
|
|
|
|
|
// strSql = String.Format(" SELECT GID,RULENAME,RULECONTENT,RULETYPE,RULEDATE,RULEYEAR,RULENOLENGTH, "
|
|
|
|
|
// + " ISSTARTUSING,ISALLOWEDITS,ISCLEAREDINEARLY,ISCOMPANY,ISDEPT "
|
|
|
|
|
// + " FROM code_rule "
|
|
|
|
|
// + "where RULENAME='{0}' and RULETYPE={1}", strRULENAME.Trim(), RULETYPE);
|
|
|
|
|
// DataSet ds = T_ALL_DA.GetAllSQL(strSql.ToString());
|
|
|
|
|
// if (ds != null)
|
|
|
|
|
// {
|
|
|
|
|
// if (ds.Tables[0].Rows.Count > 0)
|
|
|
|
|
// {
|
|
|
|
|
// if (ds.Tables[0].Rows[0]["ISSTARTUSING"].ToString().Trim().Equals("True"))
|
|
|
|
|
// {
|
|
|
|
|
// if (ds.Tables[0].Rows[0]["RULEDATE"].ToString().Trim().Equals("业务日期"))
|
|
|
|
|
// {
|
|
|
|
|
// if (tbDODATE.Text.Trim() == "")
|
|
|
|
|
// {
|
|
|
|
|
// return "";
|
|
|
|
|
// }
|
|
|
|
|
// DateTime dETD = System.Convert.ToDateTime(tbDODATE.Text.Trim());
|
|
|
|
|
// if (ds.Tables[0].Rows[0]["ISCLEAREDINEARLY"].ToString().Trim().Equals("True"))
|
|
|
|
|
// {
|
|
|
|
|
// if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4")
|
|
|
|
|
// {
|
|
|
|
|
// strRULEYEAR = dETD.ToString("yyyy") + dETD.ToString("MM");
|
|
|
|
|
// }
|
|
|
|
|
// else if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2")
|
|
|
|
|
// {
|
|
|
|
|
// strRULEYEAR = dETD.ToString("yy") + dETD.ToString("MM");
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// else
|
|
|
|
|
// {
|
|
|
|
|
// if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4")
|
|
|
|
|
// {
|
|
|
|
|
// strRULEYEAR = dETD.ToString("yyyy");
|
|
|
|
|
// }
|
|
|
|
|
// else if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2")
|
|
|
|
|
// {
|
|
|
|
|
// strRULEYEAR = dETD.ToString("yy");
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// else if (ds.Tables[0].Rows[0]["RULEDATE"].ToString().Trim().Equals("自然月份"))
|
|
|
|
|
// {
|
|
|
|
|
// DateTime fwqdate = System.Convert.ToDateTime(T_ALL_DA.GetStrSQL("fwqdate", "select fwqdate=getdate()"));
|
|
|
|
|
// if (ds.Tables[0].Rows[0]["ISCLEAREDINEARLY"].ToString().Trim().Equals("True"))
|
|
|
|
|
// {
|
|
|
|
|
// if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4")
|
|
|
|
|
// {
|
|
|
|
|
// strRULEYEAR = fwqdate.ToString("yyyy") + fwqdate.ToString("MM");
|
|
|
|
|
// }
|
|
|
|
|
// else if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2")
|
|
|
|
|
// {
|
|
|
|
|
// strRULEYEAR = fwqdate.ToString("yy") + fwqdate.ToString("MM");
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// else
|
|
|
|
|
// {
|
|
|
|
|
// if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4")
|
|
|
|
|
// {
|
|
|
|
|
// strRULEYEAR = fwqdate.ToString("yyyy");
|
|
|
|
|
// }
|
|
|
|
|
// else if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2")
|
|
|
|
|
// {
|
|
|
|
|
// strRULEYEAR = fwqdate.ToString("yy");
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// //
|
|
|
|
|
// if (ds.Tables[0].Rows[0]["ISCOMPANY"].ToString().Trim().Equals("True"))
|
|
|
|
|
// {
|
|
|
|
|
// strCODENAME = T_ALL_DA.GetStrSQL("CODENAME", "select CODENAME from [company] where GID=(select top 1 COMPANYID from user_company where USERID='" + this.hdUserID.Value.Trim() + "')");
|
|
|
|
|
// }
|
|
|
|
|
// if (ds.Tables[0].Rows[0]["ISDEPT"].ToString().Trim().Equals("True"))
|
|
|
|
|
// {
|
|
|
|
|
// strDEPTNO = T_ALL_DA.GetStrSQL("DEPTNO", "select DEPTNO from [sys_dept] where LINKID=(select top 1 COMPANYID from user_company where USERID='" + this.hdUserID.Value.Trim() + "')");
|
|
|
|
|
// }
|
|
|
|
|
// strRULECONTENT = ds.Tables[0].Rows[0]["RULECONTENT"].ToString().Trim();
|
|
|
|
|
// strRULECONTENT = strRULECONTENT.Replace("《COMPANY》", strCODENAME);
|
|
|
|
|
// strRULECONTENT = strRULECONTENT.Replace("《DEPT》", strDEPTNO);
|
|
|
|
|
// //
|
|
|
|
|
// if (ds.Tables[0].Rows[0]["RULENOLENGTH"].ToString().Trim() == "")
|
|
|
|
|
// {
|
|
|
|
|
// iRULENOLENGTH = 0;
|
|
|
|
|
// }
|
|
|
|
|
// else
|
|
|
|
|
// {
|
|
|
|
|
// iRULENOLENGTH = int.Parse(ds.Tables[0].Rows[0]["RULENOLENGTH"].ToString().Trim());
|
|
|
|
|
// }
|
|
|
|
|
// strCONTENT = strRULECONTENT + strRULEYEAR;
|
|
|
|
|
// //获取分公司的票号头字符
|
|
|
|
|
// string tempBANKSHEAD = T_ALL_DA.GetStrSQL("BANKSHEAD", "SELECT TOP 1 BANKSHEAD FROM company WHERE GID='" + strCompanyID.Trim() + "'");
|
|
|
|
|
// strCONTENT = tempBANKSHEAD + strCONTENT;
|
|
|
|
|
// //
|
|
|
|
|
// strRULENOLENGTH = T_ALL_DA.GetStrSQL(strfield, "select top 1 " + strfield + " from [wms_in] where " + strfield + " like '" + strCONTENT.Trim() + "%' and ISDELETE=0 order by " + strfield + " DESC");
|
|
|
|
|
// if (strRULENOLENGTH == "")
|
|
|
|
|
// {
|
|
|
|
|
// strRULENOLENGTH = "1";
|
|
|
|
|
// }
|
|
|
|
|
// else
|
|
|
|
|
// {
|
|
|
|
|
// strRULENOLENGTH = strRULENOLENGTH.Replace(strCONTENT.Trim(), "");
|
|
|
|
|
// inum = int.Parse(strRULENOLENGTH.Trim());
|
|
|
|
|
// inum = inum + 1;
|
|
|
|
|
// strRULENOLENGTH = inum.ToString();
|
|
|
|
|
// }
|
|
|
|
|
// int j = iRULENOLENGTH - strRULENOLENGTH.Length;
|
|
|
|
|
// for (int i = 1; i <= j; i++)
|
|
|
|
|
// {
|
|
|
|
|
// strRULENOLENGTH = "0" + strRULENOLENGTH;
|
|
|
|
|
// }
|
|
|
|
|
// //
|
|
|
|
|
// strCONTENT = strCONTENT + strRULENOLENGTH;
|
|
|
|
|
// return strCONTENT;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// return "";
|
|
|
|
|
//}
|
|
|
|
|
#endregion
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 提取规则编号
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="strRULENAME">规则项目名称</param>
|
|
|
|
|
/// <param name="strfield">需要加规则的字段</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
//protected void getCodeRuleEnabled(string strRULENAME, string strfield)
|
|
|
|
|
//{
|
|
|
|
|
// //是否生成之后允许编辑
|
|
|
|
|
// DataSet ds = T_ALL_DA.GetAllSQL("select * from code_rule where RULENAME='" + strRULENAME.Trim() + "' and RULETYPE=2");
|
|
|
|
|
// if (ds != null)
|
|
|
|
|
// {
|
|
|
|
|
// if (ds.Tables[0].Rows.Count > 0)
|
|
|
|
|
// {
|
|
|
|
|
// if (ds.Tables[0].Rows[0]["ISSTARTUSING"].ToString().Trim().Equals("True"))
|
|
|
|
|
// {
|
|
|
|
|
// if (strfield == "BSNO")
|
|
|
|
|
// {
|
|
|
|
|
// if (ds.Tables[0].Rows[0]["ISALLOWEDITS"].ToString().Trim().Equals("True"))
|
|
|
|
|
// {
|
|
|
|
|
// tbBSNO.Enabled = true;
|
|
|
|
|
// }
|
|
|
|
|
// else
|
|
|
|
|
// {
|
|
|
|
|
// tbBSNO.Enabled = false;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
}
|