Beispiel #1
0
        protected void tbxINSERT_TextChanged(object sender, EventArgs e)

        {
            //测试使用18位条码
            int len = Doc.LENCODE();

            if (tbxINSERT.Text.Length < len)
            {
                return;
            }
            List <Dictionary <string, object> > newDict1 = GridGoods.GetNewAddedList();

            if (newDict1.Count > 0)
            {
                bool result = false;
                var  list   = newDict1.Where(x => x["STR2"].ToString() == tbxINSERT.Text.Trim());
                result = list.ToList().Count > 0;

                if (result)
                {
                    Alert.Show("您输入的条码『" + tbxINSERT.Text.Trim() + "』已存在,请检查!!!", "消息提示", MessageBoxIcon.Warning);
                    tbxINSERT.Text = "";
                    tbxINSERT.Focus();
                    return;
                }
            }

            string billno = (DbHelperOra.GetSingle("SELECT SEQNO FROM DAT_CK_COM WHERE STR2 = '" + tbxINSERT.Text.Trim() + "' AND SEQNO LIKE 'DST%'") ?? "").ToString();

            if (!PubFunc.StrIsEmpty(billno))
            {
                Alert.Show("扫描定数条码已存在单据【" + billno + "】中,请检查!", "提示信息", MessageBoxIcon.Warning);
                tbxINSERT.Text = "";
                tbxINSERT.Focus();
                return;
            }
            //检查条码状态
            if (!DbHelperOra.Exists("select 1 from DAT_GOODSDS_LOG where BARCODE = '" + tbxINSERT.Text.Trim() + "' and FLAG = 'N'"))
            {
                Alert.Show("扫描定数条码不存在或已被回收使用!", "提示信息", MessageBoxIcon.Warning);
                tbxINSERT.Text = "";
                tbxINSERT.Focus();
                return;
            }
            if (docDEPTOUT.SelectedValue == "" || docDEPTID.SelectedValue == "")
            {
                //docDEPTID.SelectedValue = tbxINSERT.Text.Substring(9, 4);
                //docDEPTOUT.SelectedValue = tbxINSERT.Text.Substring(7, 2);
                docDEPTID.SelectedValue  = Doc.ONECODE(tbxINSERT.Text.Trim(), "DEPTIN");
                docDEPTOUT.SelectedValue = Doc.ONECODE(tbxINSERT.Text.Trim(), "DEPTOUT");
            }
            else
            {
                if (docDEPTID.SelectedValue != Doc.ONECODE(tbxINSERT.Text.Trim(), "DEPTIN"))
                {
                    string DEPTIN = Doc.ONECODE(tbxINSERT.Text.Trim(), "DEPTIN");
                    Alert.Show("扫描定数条码退货科室应为[" + DEPTIN + "],非[" + docDEPTID.SelectedText + "]科室条码,请检查!", "操作提示", MessageBoxIcon.Warning);
                    tbxINSERT.Text = "";
                    tbxINSERT.Focus();
                    return;
                }
                if (docDEPTOUT.SelectedValue != Doc.ONECODE(tbxINSERT.Text.Trim(), "DEPTOUT"))
                {
                    string DEPTOUT = Doc.ONECODE(tbxINSERT.Text.Trim(), "DEPTOUT");
                    Alert.Show("扫描定数条码退货库房应为[" + DEPTOUT + "],非[" + docDEPTOUT.SelectedText + "]库房出货,请检查!", "操作提示", MessageBoxIcon.Warning);
                    tbxINSERT.Text = "";
                    tbxINSERT.Focus();
                    return;
                }
            }

            List <Dictionary <string, object> > newDict = GridGoods.GetNewAddedList().ToList();

            for (int i = 0; i < newDict.Count; i++)
            {
                string barcode_old = newDict[i]["STR2"].ToString();
                if (barcode_old == tbxINSERT.Text.Trim())
                {
                    Alert.Show("扫描定数条码已存在!", "提示信息", MessageBoxIcon.Warning);
                    tbxINSERT.Text = "";
                    tbxINSERT.Focus();
                    return;
                }
            }
            //测试截取前6位
            //string code = tbxINSERT.Text.Trim().Substring(13, 12);
            string code = Doc.ONECODE(tbxINSERT.Text.Trim(), "GDSEQ");
            string dept = docDEPTID.SelectedValue;
            //从LOG表中取得记录数量
            DataTable dhnum = DbHelperOra.QueryForTable("select A.*,F_GETUNITNAME(UNIT) UNITNAME,F_GETPRODUCERNAME(PRODUCER) PRODUCERNAME,F_GETGOODSHW(a.GDSEQ,'" + dept + "') hwname from DAT_CK_COM A where A.STR2 = '" + tbxINSERT.Text.Trim() + "'");

            if (!string.IsNullOrWhiteSpace(code) && code.Trim().Length >= 2)
            {
                if (dhnum != null && dhnum.Rows.Count > 0)
                {
                    foreach (DataRow dr in dhnum.Rows)
                    {
                        dr["ROWNO"] = GridGoods.GetMergedData().Count() + 1;
                        dr["STR2"]  = tbxINSERT.Text.Trim();
                        dr["HWID"]  = dr["hwname"];
                        LoadGridRow(dr, false);
                    }
                }
                else
                {
                    Alert.Show(string.Format("{0}尚未配置商品【{1}】!!!", docDEPTID.SelectedText, code), MessageBoxIcon.Warning);
                }
                tbxINSERT.Text = "";
            }
            if (docDEPTID.Enabled)
            {
                docDEPTID.Enabled = false;
            }
            if (docDEPTOUT.Enabled)
            {
                docDEPTOUT.Enabled = false;
            }
            if (!tbxINSERT.Enabled)
            {
                tbxINSERT.Enabled = true;
            }
            tbxINSERT.Focus();
        }