zzr99
2022-01-19 dfd0831df7b8245b7af6b6be28efd18b29fab17d
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
112
113
114
115
116
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
 
namespace DAL
{
    public  class ClsProduct_Add:DBUtility.ClsXt_BaseBill
    {
        public Model.ClsProduct_Base omodel1 = new Model.ClsProduct_Base();
        public Model.ClsProduct_gyjd omodel2 = new Model.ClsProduct_gyjd();
        public Model.ClsProduct_material omodel3 = new Model.ClsProduct_material();
 
        public SQLHelper.ClsCNK3 oCn = new SQLHelper.ClsCNK3();
 
        public ClsProduct_Add()
        {
            base.MvarItemKeySub = "Product_Base";
            base.MvarItemKeySub2 = "";
            base.MvarItemKeySub3 = "";
            base.MvarItemKeySub4 = "";
            base.MvarItemKey = "Product_Base";
            base.MvarReportTitle = "费用单明细记录";
            base.BillType = "18020"; 
        }
 
        #region 固定代码
 
        ~ClsProduct_Add()
        {
 
        }
       
        #endregion   自定义方法
 
        //修改单据
        public override bool DeleteBill(long lngBillKey, ref string sReturn)
        {
            try
            {
                oCn.BeginTran();
                //删除重复记录
                //oCn.RunProc("Delete From CB_ItemMoneyBill_Tmp where HYear=" + omodel.HYear.ToString() + " and HPeriod=" + omodel.HPeriod.ToString() + " and HItMoneyID=" + omodel.HItMoneyID.ToString());
                sReturn = "删除单据成功!";
                oCn.Commit();
                return true;
            }
            catch (Exception e)
            {
                sReturn = e.Message;
                oCn.RollBack();
                throw (e);
            }
        }
 
        //新增单据
        public override bool AddBill(ref string sReturn)
        {
            try
            {
                DataSet Ds = new DataSet();
                oCn.BeginTran();
                //主表
                oCn.RunProc("Insert Into Product_Base " +
                "(kname,pname,ptuhao,jixing,pcolour,qita" +
                ") " +
                " values('" + omodel1.kname + "','" + omodel1.pname + "','" + omodel1.ptuhao + "','" + omodel1.jixing + "','" + omodel1.pcolour + "','" + omodel1.qita + "'" +
                ") ");
                //得到物料ID
                //Ds = oCn.RunProcReturn("select id from Product_Base where kname='" + omodel1.kname + "' and pname='" + omodel1.pname + "' and ptuhao='" + omodel1.ptuhao + "' and jixing='" + omodel1.jixing + "' and pcolour='" + omodel1.pcolour + "' and qita='" + omodel1.qita + "' order by id");
                Ds = oCn.RunProcReturn("select @@IDENTITY", "Product_Base");
                if (Ds == null || Ds.Tables[0].Rows.Count == 0)
                {
                    return false;
                }
                else
                {
                    omodel1.HInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0][0]);
                }
                //
                oCn.RunProc("Insert Into Product_gyjd " +
                "(product_id,strg1,strg2,strg3,strg4,strg5" +
                ",strg6,strg7,strg8,strg9,strg10" +
                ",strg11,strg12,strg13,strg14" +
                ") " +
                " values(" + omodel1.HInterID.ToString() + ",'" + omodel2.strg1 + "','" + omodel2.strg2 + "','" + omodel2.strg3 + "','" + omodel2.strg4 + "','" + omodel2.strg5 + "'" +
                ",'" + omodel2.strg6 + "','" + omodel2.strg7 + "','" + omodel2.strg8 + "','" + omodel2.strg9 + "','" + omodel2.strg10 + "'" +
                ",'" + omodel2.strg11 + "','" + omodel2.strg12 + "','" + omodel2.strg13 + "','" + omodel2.strg14 + "'" +
                ") ");
                //
                oCn.RunProc("Insert Into Product_material " +
                "(product_id,strm1,strm2,strm3,strm4,strm5" +
                ",strm6,strm7,strm8,strm9,strm10" +
                ",strm11,strm12,strm13,strm14,strm15,strm16" +
                ") " +
                " values(" + omodel1.HInterID.ToString() + ",'" + omodel3.strm1 + "','" + omodel3.strm2 + "','" + omodel3.strm3 + "','" + omodel3.strm4 + "','" + omodel3.strm5 + "'" +
                ",'" + omodel3.strm6 + "','" + omodel3.strm7 + "','" + omodel3.strm8 + "','" + omodel3.strm9 + "','" + omodel3.strm10 + "'" +
                ",'" + omodel3.strm11 + "','" + omodel3.strm12 + "','" + omodel3.strm13 + "','" + omodel3.strm14 + "','" + omodel3.strm15 + "','" + omodel3.strm16 + "'" +
                ") ");
                sReturn = "新增单据成功!";
                oCn.Commit();
                return true;
            }
            catch (Exception e)
            {
                sReturn = e.Message;
                oCn.RollBack();
                throw (e);
            }
        }
 
 
 
 
    }
}