yangle
2023-06-25 6585cda35b87eb1a3a05a948faf7dc5d08ef8ff7
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
106
107
108
109
110
111
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();
        } 
    }
}