1
duhe
4 小时以前 861a3c22b5963be9ce8fd4e2bf72b85333bd047b
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
 
namespace BLL
{
    public class ClsSc_AssemblyBill
    {
        /// <summary>
        /// 扫描成品条码 并返回相关信息,判断是否有效条码
        /// </summary>
        /// <param name="sCPCode">成品编码</param>
        /// <param name="HBillType">单据类型</param>
        /// <param name="sICMOBillNo">任务单号</param>
        /// <param name="sCPBarCode">成品条码</param>
        /// <param name="sCPMaterID">成品内码</param>
        /// <param name="sCPMaterName">成品名称</param>
        /// <param name="sBillNo">单据号</param>
        /// <param name="sInterID">单据内码</param>
        /// <param name="sErrMsg">错误信息</param>
        /// <returns></returns>
        public bool Get_Assembly_CPBarCode(string sCPCode, string HBillType, ref string sICMOBillNo, ref string sCPBarCode, ref Int64 sCPMaterID, ref string sCPMaterName, ref string sBillNo, ref Int64 sInterID, ref string sErrMsg)
        {
            SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
            DAL.ClsGy_BarCodeBill_View dal = new DAL.ClsGy_BarCodeBill_View();
            //
            try
            {
                //判断所扫描条码是否有效
                if (dal.GetInfoByNumber_View(sCPCode))
                {
                    //判断成品条码是否存在组装单记录
                    DataSet ds = oCn.RunProcReturn("exec h_p_Sc_AssemblyBill_CPBarCode '" + sCPCode + "'", "h_p_Sc_AssemblyBill_CPBarCode");
                    if (ds == null || ds.Tables[0].Rows.Count == 0)
                    {
                        sErrMsg = "扫描成品条码信息,未知错误!";
                        return false;
                    }
                    else
                    {
                        //已存在组装单记录,编辑状态,获取原组装单单据内码、单据号
                        if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) == "Modify")
                        {
                            sICMOBillNo = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HICMOBillNo"]);
                            sCPBarCode = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HCPBarCode"]);
                            sCPMaterID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HCPMaterID"]);
                            sCPMaterName = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HCPMaterName"]);
                            sInterID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HInterID"]);
                            sBillNo = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBillNo"]);
                            return true;
                        }
                        else if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) == "AddNew")
                        //不存在组装单记录,新增状态,获取最大组装单单据内码、单据号
                        {
                            sICMOBillNo = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HICMOBillNo"]);
                            sCPBarCode = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HCPBarCode"]);
                            sCPMaterID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HCPMaterID"]);
                            sCPMaterName = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HCPMaterName"]);
                            sInterID = DBUtility.ClsPub.CreateBillID_Prod(HBillType, ref sErrMsg);
                            sBillNo = DBUtility.ClsPub.CreateBillCode_Prod(HBillType, ref sErrMsg, true);
                            return true;
                        }
                        else
                        {
                            sErrMsg = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]);
                            return false;
                        }
                    }
                }
                else
                {
                    sErrMsg = "无效条码";
                    return false;
                }
            }
            catch (Exception e)
            {
                sErrMsg = "扫描成品条码失败!" + e.Message;
                return false;
            }
        }
 
        /// <summary>
        /// 扫描配件条码  并返回相关信息,判断是否有效条码
        /// </summary>
        /// <param name="sPJCode">配件代码</param>
        /// <param name="sCPCode">成品代码</param>
        /// <param name="sInterID">内码</param>
        /// <param name="sBillNo">单据号</param>
        /// <param name="sMaker">制单人</param>
        /// <param name="HWorkerID">操作员</param>
        /// <param name="HSNNumber">SN号</param>
        /// <param name="sErrMsg">错误信息</param>
        /// <returns></returns>
        public bool Get_Assembly_PJBarCode(string sPJCode, string sCPCode, long sInterID, string sBillNo, string sMaker, long HWorkerID, string HSNNumber, ref string sErrMsg)
        {
            SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
            DAL.ClsGy_BarCodeBill_View dal = new DAL.ClsGy_BarCodeBill_View();
            //
            try
            {
                if (dal.GetInfoByNumber_View(sPJCode))
                {
                    if (sPJCode == sCPCode)
                    {
                        sErrMsg = "所扫描配件条码与成品条码不允许相同!";
                        return false;
                    }
 
                    DataSet ds = oCn.RunProcReturn("exec h_p_Sc_AssemblyBill_PJBarCode '" + sPJCode + "','" + sCPCode + "'," + sInterID.ToString() + ",'" + sBillNo + "','" + sMaker + "'," + HWorkerID.ToString() + ",'" + HSNNumber + "'", "h_p_Sc_AssemblyBill_PJBarCode");
                    if (ds == null || ds.Tables[0].Rows.Count == 0)
                    {
                        sErrMsg = "扫描配件条码信息,未知错误!";
                        return false;
                    }
                    else
                    {
                        if (DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0][0]) == 0)
                        {
                            return true;
                        }
                        else
                        {
                            sErrMsg = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HRemark"]);
                            return false;
                        }
                    }
                }
                else
                {
                    sErrMsg = "无效条码";
                    return false;
                }
            }
            catch (Exception e)
            {
                sErrMsg = "扫描配件条码失败!" + e.Message;
                return false;
            }
        }
 
        /// <summary>
        /// 根据内码 返回组装单信息
        /// </summary>
        /// <param name="HInterID">内码</param>
        /// <param name="sBillType">单据类型</param>
        /// <param name="sWhere">过滤条件</param>
        /// <returns></returns>
        public DataSet GetSc_AssemblyBill(long HInterID, string sBillType, string sWhere,ref string sErr)
        {
            SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
            //
            try
            {
                DataSet DS = oCn.RunProcReturn("exec h_p_Sc_AssemblyBillList " + HInterID, "h_p_Sc_AssemblyBillList");
                //DataSet DS = oCn.RunProcReturn("Select * from h_v_Sc_AssemblyBill Where HInterID=" + HInterID.ToString() + " and HBillType='" + sBillType + "' " + sWhere, "h_v_Sc_AssemblyBill", ref DBUtility.ClsPub.sExeReturnInfo);
                if (DS == null || DS.Tables[0].Rows.Count == 0)
                {
                    return null;
                }
                else
                {
                    return DS;
                }
            }
            catch (Exception e)
            {
                sErr = sErr + "," + e.Message;
                throw (e);
            }
        }
 
        /// <summary>
        /// 根据内码及条形码,删除对应数据
        /// </summary>
        /// <param name="HInterID"></param>
        /// <param name="HBarCode"></param>
        /// <param name="sErrMsg"></param>
        /// <returns></returns>
        public bool set_DelSc_AssemblyBill(long HInterID, string HBarCode, ref string sErrMsg)
        {
            SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
            try
            {
                oCn.RunProc("Delete from Sc_AssemblyBillSub where HInterID=" + HInterID.ToString() + " and HBarCode='" + HBarCode + "'", ref DBUtility.ClsPub.sExeReturnInfo);
                return true;
            }
            catch (Exception e)
            {
                sErrMsg = "删除失败!" + e.Message;
                return false;
            }
        }
 
 
    }
}