yusijie
2023-10-13 d9d66b51a9643194ce2b29053a3fc187eb7bdaf1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
 
namespace BLL
{
    public class ClsGy_MaxNum_Ctl:DBUtility.ClsGy_Base_Ctl 
    {
        SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); 
        //原代码 用于 替换子项目
        public string HOldNumber;
        public ClsGy_MaxNum_Model oModel = new ClsGy_MaxNum_Model();
        //新增
        public   bool AddNew( ref string sReturn)
        {
            try
            {
                //是否重复单据类型
                //if (HavBillCode(oModel.BillCode))
                //{
                //    sReturn = "单据类型重复!";
                //    return false;
                //}
                oCn.BeginTran();
                oCn.RunProc("Insert into " + MvarItemKey + " " +
                    " (BillCode,WhCode,KjYear,Period,NowNumber) " +
                    " Values('" + oModel.BillCode + "','" + oModel.WhCode + "'," + oModel.KjYear.ToString() + "," + oModel.Period.ToString() + "," + oModel.NowNumber.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 " +
                    " WhCode='" + oModel.WhCode + "'" +
                    ",BillCode='" + oModel.BillCode + "'" +
                    ",KjYear=" + oModel.KjYear.ToString() +
                    ",Period=" + oModel.Period.ToString() +
                    ",NowNumber=" + oModel.NowNumber.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, string sWhCode)
        {
            try
            {
                oCn.RunProc("Delete from " + MvarItemKey + " where BillCode='" + sCode + "'and WhCode='" + sWhCode + "'", ref Pub_Class.ClsPub.sExeReturnInfo);
                return true;
            }
            catch (Exception e)
            {
                throw (e);
            }
        } 
        //构造函数
        public ClsGy_MaxNum_Ctl()
        {
            MvarItemKey = "Gy_MaxNum";
            MvarReportTitle = "单据内码规则表设置";
            oModel = new ClsGy_MaxNum_Model();
        } 
    }
}