Example #1
0
        protected override void PrepareModelToSave()
        {
            var _CM = this.CurrentModel as MWare_Bill;

            if (null == _DC || null == _CM)
            {
                MessageErp.ErrorMessage(ErpUIText.ErrMsg); return;
            }
            base.PrepareModelToSave();
            //
            _CM.Sub_SD = new List <MWare_Bill_SD>();
            MWare_Bill_SD sub_SD = null;

            for (int i = 0; i <= 1; i++)
            {
                sub_SD = new MWare_Bill_SD()
                {
                    ID       = _CM.ID,
                    CYL      = i == 0 ? _DC.CYLR.Value : _DC.CYLL.Value,
                    Qty      = i == 0 ? _DC.QtyR.Value : _DC.QtyL.Value,
                    SPH      = i == 0 ? _DC.SPHR.Value : _DC.SPHL.Value,
                    LensCode = i == 0 ? _DC.LensCodeR.Trim() : _DC.LensCodeL.Trim(),
                    X_ADD    = i == 0 ? _DC.X_ADDR.Value : _DC.X_ADDL.Value,
                    Price    = 0,
                    F_LR     = i == 0 ? "R" : "L",
                };
                _CM.Sub_SD.Add(sub_SD);
            }
        }
        private void AddBarCodePre()
        {
            MWare_Bill model = new MWare_Bill()
            {
                BarCodeL     = this.BillMain.BarCodeL,
                BarCodeR     = this.BillMain.BarCodeR,
                BarCodeSOPre = this.BillMain.BarCodeSOPre,
                BCode        = "",
                BDate        = DateTime.Now,
                BType        = "KFPSOSD",
                CusCode      = "",
                F_SD         = true,
                FBCode       = "",
                F_IO         = false,
                ID           = "",
                Maker        = USysInfo.UserCode,
                MName        = USysInfo.UserName,
                MType        = "L",
                Remark       = "",
                SpCode       = "",
                Sub_SD       = new List <MWare_Bill_SD>(),
                WhCode       = this.BillMain.WhCode,
            };

            MWare_Bill_SD model_R = new MWare_Bill_SD()
            {
                ID       = "",
                LensCode = this.BillMain.LensCodeR,
                SPH      = this.BillMain.SPHR.Value,
                CYL      = this.BillMain.CYLR.Value,
                X_ADD    = this.BillMain.X_ADDR.Value,
                F_LR     = "R",
                Qty      = this.BillMain.QtyR.Value,
                Price    = 0,
            };

            model.Sub_SD.Add(model_R);

            MWare_Bill_SD model_L = new MWare_Bill_SD()
            {
                ID       = "",
                LensCode = this.BillMain.LensCodeL,
                SPH      = this.BillMain.SPHL.Value,
                CYL      = this.BillMain.CYLL.Value,
                X_ADD    = this.BillMain.X_ADDL.Value,
                F_LR     = "L",
                Qty      = this.BillMain.QtyL.Value,
                Price    = 0,
            };

            model.Sub_SD.Add(model_L);

            model.Sub_Extend = new MWare_Bill_Extend()
            {
                ID        = "",
                LensCodeR = this.BillMain.LensCodeR,
                SPHR      = this.BillMain.SPHR.Value,
                CYLR      = this.BillMain.CYLR.Value,
                X_ADDR    = this.BillMain.X_ADDR.Value,
                LensCodeL = this.BillMain.LensCodeL,
                SPHL      = this.BillMain.SPHL.Value,
                CYLL      = this.BillMain.CYLL.Value,
                X_ADDL    = this.BillMain.X_ADDL.Value,
                SCode     = "",
                SumQty    = this.BillMain.QtyR.Value + this.BillMain.QtyL.Value
            };

            DSWare_Bill _DS = new DSWare_Bill();

            _DS.Add(USysInfo.DBCode, USysInfo.LgIndex, model, geted =>
            {
                if (geted.HasError)
                {
                    MessageErp.ErrorMessage(geted.Error.Message.GetErrMsg());
                    geted.MarkErrorAsHandled();
                    return;
                }

                this.ResetBillMain();
            }, null);
        }