using System;
|
using System.Collections.Generic;
|
using System.Text;
|
using System.Data;
|
|
namespace BLL
|
{
|
public class ClsGy_BillNumber_Ctl:DBUtility.ClsGy_Base_Ctl
|
{
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
//原代码 用于 替换子项目
|
public string HOldNumber;
|
public ClsGy_BillNumber_Model oModel = new ClsGy_BillNumber_Model();
|
//新增
|
public bool AddNew( ref string sReturn)
|
{
|
try
|
{
|
//是否重复单据类型
|
if (HavBillCode(oModel.BillCode))
|
{
|
sReturn = "单据类型重复!";
|
return false;
|
}
|
oCn.BeginTran();
|
oCn.RunProc("Insert into " + MvarItemKey + " " +
|
" (BillType,BillCode,BillName,BillCodeMode,Profix" +
|
",CodeLen,TotalLen,Glida,IDNow) " +
|
" Values('" + oModel.BillType + "','" + oModel.BillCode + "','" + oModel.BillName + "'," + oModel.BillCodeMode.ToString() + ",'" + oModel.Profix + "'" +
|
"," + oModel.CodeLen.ToString() + "," + oModel.TotalLen.ToString() + "," + oModel.Glida.ToString() + "," + oModel.IDNow.ToString() +
|
")", ref DBUtility.ClsPub.sExeReturnInfo);
|
oCn.Commit();
|
sReturn = "保存成功!";
|
return true;
|
}
|
catch (Exception e)
|
{
|
oCn.RollBack();
|
sReturn = "保存失败!";
|
throw (e);
|
}
|
}
|
|
//修改
|
public bool ModifyByID(string sItemID)
|
{
|
try
|
{
|
oCn.BeginTran();
|
oCn.RunProc("Update " + MvarItemKey + " set " +
|
" BillType='" + oModel.BillType + "'" +
|
//",BillCode='" + oModel.BillCode + "'" +
|
",BillName='" + oModel.BillName + "'" +
|
",BillCodeMode=" + oModel.BillCodeMode.ToString() +
|
",Profix='" + oModel.Profix + "'" +
|
",CodeLen=" + oModel.CodeLen.ToString() +
|
",TotalLen=" + oModel.TotalLen.ToString() +
|
",Glida=" + oModel.Glida.ToString() +
|
",IDNow=" + oModel.IDNow.ToString() + " Where BillCode='" + sItemID+"'", ref DBUtility.ClsPub.sExeReturnInfo);
|
oCn.Commit();
|
return true;
|
}
|
catch (Exception e)
|
{
|
oCn.RollBack();
|
throw (e);
|
}
|
}
|
|
//重复单据类型
|
public bool HavBillCode(string sItemID)
|
{
|
DataSet DS;
|
try
|
{
|
DS = oCn.RunProcReturn("Select BillCode from " + MvarItemKey + " Where BillCode = '" + sItemID + "'", MvarItemKey, ref Pub_Class.ClsPub.sExeReturnInfo);
|
if (DS.Tables[0].Rows.Count == 0)
|
return false;
|
else
|
{
|
oModel.BillCode = Convert.ToString(DS.Tables[0].Rows[0]["BillCode"]);
|
return true;
|
}
|
}
|
catch (Exception e)
|
{
|
throw (e);
|
}
|
}
|
//删除
|
public bool DeleteByCode(string sCode)
|
{
|
try
|
{
|
oCn.RunProc("Delete from " + MvarItemKey + " where BillCode='" + sCode + "'", ref Pub_Class.ClsPub.sExeReturnInfo);
|
return true;
|
}
|
catch (Exception e)
|
{
|
throw (e);
|
}
|
}
|
//构造函数
|
public ClsGy_BillNumber_Ctl()
|
{
|
MvarItemKey = "Gy_BillNumber";
|
MvarReportTitle = "单据编号规则表设置";
|
oModel = new ClsGy_BillNumber_Model();
|
}
|
}
|
}
|