Esempio n. 1
0
        //点击生成条码按钮
        protected void cmdCreateBarCode_ServerClick(object sender, System.EventArgs e)
        {
            if (_WarehouseFacade == null)
            {
                _WarehouseFacade = new WarehouseFacade(base.DataProvider);
            }
            //点击生成条码按钮,根据数量输入框输入的数量生成箱号数,显示在Grid中并保存在TBLBARCODE表中
            //4.	鼎桥箱号编码规则:CT+年月日+九位流水码:如:CT20160131000000001,流水码不归零(流水码创建对应的Sequences累加)
            if (string.IsNullOrEmpty(txtQtyEdit.Text.Trim()))
            {
                WebInfoPublish.Publish(this, "数量不能为空", this.languageComponent1);
                return;
            }
            int qty = int.Parse(txtQtyEdit.Text.Trim());

            if (qty == 0)
            {
                WebInfoPublish.Publish(this, "数量只能输入大于0的数字", this.languageComponent1);
                return;
            }
            DBDateTime dbDateTime  = FormatHelper.GetNowDBDateTime(this.DataProvider);
            int        date        = dbDateTime.DBDate;
            string     barCodeList = "";

            try
            {
                this.DataProvider.BeginTransaction();
                for (int i = 0; i < qty; i++)
                {
                    BarCode bar      = new BarCode();
                    string  serialNo = CreateSerialNo(date);
                    bar.BarCodeNo = "CT" + date + serialNo;
                    bar.Type      = "CARTONNO";
                    bar.MCode     = "";
                    bar.EnCode    = "";
                    bar.SpanYear  = date.ToString().Substring(0, 4);
                    bar.SpanDate  = date;
                    if (!string.IsNullOrEmpty(serialNo))
                    {
                        bar.SerialNo = int.Parse(serialNo);
                    }
                    bar.PrintTimes   = 0;
                    bar.CUser        = this.GetUserCode(); //	CUSER
                    bar.CDate        = dbDateTime.DBDate;  //	CDATE
                    bar.CTime        = dbDateTime.DBTime;  //	CTIME
                    bar.MaintainDate = dbDateTime.DBDate;  //	MDATE
                    bar.MaintainTime = dbDateTime.DBTime;  //	MTIME
                    bar.MaintainUser = this.GetUserCode(); //	MUSER
                    _WarehouseFacade.AddBarCode(bar);
                    barCodeList += "'" + bar.BarCodeNo + "',";
                }
                this.DataProvider.CommitTransaction();
            }
            catch (Exception ex)
            {
                this.DataProvider.RollbackTransaction();
                WebInfoPublish.PublishInfo(this, ex.Message, this.languageComponent1);
            }
            if (!string.IsNullOrEmpty(barCodeList))
            {
                if (string.IsNullOrEmpty(txtBarCodeListQuery.Text))
                {
                    txtBarCodeListQuery.Text = barCodeList.Substring(0, barCodeList.Length - 1);
                }
                else
                {
                    txtBarCodeListQuery.Text += ",";
                    txtBarCodeListQuery.Text += barCodeList.Substring(0, barCodeList.Length - 1);
                }
            }
            cmdQuery_Click(null, null);
        }