zzr99
2022-04-25 e5e8b23083cd7f09ebe3c110e84cfad7747eba49
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
using System;
using System.Collections.Generic;
using System.Text;
using System.Data; 
 
namespace DAL
{
    /// <summary>
    /// 生产排程 保存 生产人员  1对多
    /// </summary>
    public  class ClsSc_ICMOSortBill_Group
    {
 
        public string MvarItemKey;
        public string MvarReportTitle;
 
        public Model.ClsSc_ICMOSortBill_GroupMain omodel = new Model.ClsSc_ICMOSortBill_GroupMain();
        public List<Model.ClsSc_ICMOSortBill_GroupSub> DetailColl = new List<Model.ClsSc_ICMOSortBill_GroupSub>();
        SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
        public bool FillTag = false;
        public ClsSc_ICMOSortBill_Group()
        {
            MvarItemKey = "3708";
            MvarReportTitle = "生产计划排程";
        }
 
        #region 固定代码
        
        ~ClsSc_ICMOSortBill_Group()
        {
            DetailColl = null;
        }
        //删除子表
        public void DeleteBillSub(Int64 lngBillKey)
        {
            //oCn.RunProc("Delete From Sc_ICMOSortBillSub where HInterID=" + lngBillKey.ToString());
        }
        //删除主表
        public void DeleteBillMain(Int64 lngBillKey)
        {
            //oCn.RunProc("Delete From Sc_ICMOSortBillMain where HInterID=" + lngBillKey.ToString());
        }
        //删除单据
        public bool DeleteBill(Int64 lngBillKey, ref string sReturn)
        {
            //try
            //{
            //    oCn.BeginTran();
            //    //删除关联 
            //    //删除明细表
            //    //DeleteBillSub(lngBillKey);
            //    //删除主表
            //    DeleteBillMain(lngBillKey);
            //    sReturn = "删除单据成功!";
            //    oCn.Commit();
            return true;
            //}
            //catch (Exception e)
            //{
            //    sReturn = e.Message;
            //    oCn.RollBack();
            //    return false;
            //}
        }
       
    
        #endregion
        
        //新增单据
        public bool AddBill(ref string sReturn)
        {
            try
            {
                //若MAINDI重复则重新获取
                oCn.BeginTran();
                oCn.RunProc("delete from Sc_ICMOSortBill_Group where HICMOInterID=" + omodel.HICMOInterID.ToString() + " and HSplitNO='" + omodel.HSplitNO + "' and HSourceID=" + omodel.HSourceID.ToString() + " and HGroupID=" + omodel.HGroupID.ToString());
                //主表
                //
                //插入子表
                foreach (Model.ClsSc_ICMOSortBill_GroupSub oSub in DetailColl)
                {
                    oCn.RunProc("Insert into Sc_ICMOSortBill_Group " +
                       " (HICMOInterID,HICMOBillNo,HSplitNO,HMaterID" +
                       ",HSourceID,HGroupID,HEmpID" +
                       ") " +
                       " values ("
                       + omodel.HICMOInterID.ToString() + ",'" + omodel.HICMOBillNo.ToString() + "','" + omodel.HSplitNO.ToString() + "'," + omodel.HMaterID.ToString() +
                       "," + omodel.HSourceID.ToString() + "," + omodel.HGroupID.ToString() + "," + oSub.HEmpID.ToString() +
                       ") ");
                }
                
                sReturn = "新增单据成功!";
                oCn.Commit();
                //
                return true;
            }
            catch (Exception e)
            {
                sReturn = e.Message;
                oCn.RollBack();
                return false;
            }
        }
        //显示单据
        public bool ShowBill(Int64 HICMOInterID, string HSplitNO, Int64 HSourceID, Int64 HGroupID, ref string sReturn)
        {
            try
            {
                //查询主表
                DataSet Ds;
                DataSet DsSub;
                Ds = oCn.RunProcReturn("Select * from Sc_ICMOSortBill_Group where HICMOInterID=" + HICMOInterID.ToString() + " and HSplitNO='" + HSplitNO + "' and HSourceID=" + HSourceID.ToString() + " and HGroupID=" + HGroupID.ToString(), "Sc_ICMOSortBill_Group");
                if (Ds.Tables[0].Rows.Count == 0)
                {
                    sReturn = "单据未找到!";
                    return false;
                }
                //赋值
                omodel.HMaterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HMaterID"]);
                omodel.HGroupID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HGroupID"]);
                omodel.HSourceID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HSourceID"]);
                omodel.HSplitNO = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HSplitNO"].ToString());
                //
                omodel.HICMOInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HICMOInterID"]);
                omodel.HICMOBillNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HICMOBillNo"].ToString());
                //
                DsSub = oCn.RunProcReturn("Select * from Sc_ICMOSortBill_Group where HICMOInterID=" + omodel.HICMOInterID.ToString() + " and HSplitNO='" + omodel.HSplitNO + "' and HSourceID=" + omodel.HSourceID.ToString() + " and HGroupID=" + omodel.HGroupID.ToString(), "Sc_ICMOSortBill_Group");
                DetailColl.Clear();//清空
                for (int j = 0; j < DsSub.Tables[0].Rows.Count; j++)
                {
                    Model.ClsSc_ICMOSortBill_GroupSub oSub = new Model.ClsSc_ICMOSortBill_GroupSub();
                    oSub.HEmpID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[j]["HEmpID"]);
                    DetailColl.Add(oSub);
                }
                //
                
                sReturn = "显示单据成功!";
                return true;
            }
            catch (Exception e)
            {
                sReturn = e.Message;
                return false;
            }
        }
 
 
 
 
 
 
    }
 
}