Example #1
0
        public void AddPrice(string dbCode, int lgIndex, MSale_PriceTemplate_Lens t)
        {
            var           model  = t;
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Sale_PriceTemplate_Lens(");
            strSql.Append("ID,LensCode,SPH1,SPH2,CYL1,CYL2,ADD1,ADD2,Dia,P1,P2)");
            strSql.Append(" values (");
            strSql.Append("(select HKOERP.dbo.SF_GetID()),@LensCode,@SPH1,@SPH2,@CYL1,@CYL2,@ADD1,@ADD2,@Dia,@P1,@P2)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@LensCode", SqlDbType.VarChar, 30),
                new SqlParameter("@SPH1",     SqlDbType.Int,      4),
                new SqlParameter("@SPH2",     SqlDbType.Int,      4),
                new SqlParameter("@CYL1",     SqlDbType.Int,      4),
                new SqlParameter("@CYL2",     SqlDbType.Int,      4),
                new SqlParameter("@ADD1",     SqlDbType.Int,      4),
                new SqlParameter("@ADD2",     SqlDbType.Int,      4),
                new SqlParameter("@Dia",      SqlDbType.Int,      4),
                new SqlParameter("@P1",       SqlDbType.Decimal,  9),
                new SqlParameter("@P2",       SqlDbType.Decimal, 9)
            };
            parameters[0].Value = model.LensCode;
            parameters[1].Value = model.SPH1;
            parameters[2].Value = model.SPH2;
            parameters[3].Value = model.CYL1;
            parameters[4].Value = model.CYL2;
            parameters[5].Value = model.ADD1;
            parameters[6].Value = model.ADD2;
            parameters[7].Value = model.Dia;
            parameters[8].Value = model.P1;
            parameters[9].Value = model.P2;
            DALHelper.ExecuteSql(dbCode, strSql.ToString(), parameters);
        }
        private void AddPrice()
        {
            if (this.ViewErrList != null && this.ViewErrList.Value.Count > 0)
            {
                return;
            }

            if (string.IsNullOrEmpty(this.SKeyCode.Trim()))
            {
                return;
            }

            this._F_LoadDefaultRange = false;

            var s1  = this.SPH1;
            var s2  = this.SPH2;
            var c1  = this.CYL1;
            var c2  = this.CYL2;
            var a1  = this.ADD1;
            var a2  = this.ADD2;
            var dia = this.Dia;
            var p1  = this.P1;
            var p2  = this.P2;
            MSale_PriceTemplate_Lens model = new MSale_PriceTemplate_Lens()
            {
                ADD1     = a1,
                ADD2     = a2,
                CYL1     = c1,
                CYL2     = c2,
                Dia      = dia,
                ID       = "",
                LensCode = this.SKeyCode,
                P1       = p1,
                P2       = p2,
                SPH1     = s1,
                SPH2     = s2
            };
            DSSale_PriceTemplate_Lens _DS = new DSSale_PriceTemplate_Lens();

            this.IsBusy = true;
            _DS.AddPrice(USysInfo.DBCode, USysInfo.LgIndex, model, geted =>
            {
                this.IsBusy = false;
                if (geted.HasError)
                {
                    MessageErp.ErrorMessage(geted.Error.Message.GetErrMsg());
                    geted.MarkErrorAsHandled();
                    return;
                }
                this.Search();
            }, null);
        }