Example #1
0
        public M_Arrive_Result CheckArrive(string code, double money)
        {
            M_Arrive_Result result = new M_Arrive_Result();

            try
            {
                if (string.IsNullOrEmpty(code))
                {
                    throw new Exception("The coupon number cannot be empty");
                }
                if (money < 1)
                {
                    throw new Exception("Incorrect order amount");
                }
                M_Ex_Coupon cupMod = SelModelByCode(code);
                if (cupMod == null)
                {
                    throw new Exception("Coupon do not exist");
                }
                if (cupMod.ZStatus != 1)
                {
                    throw new Exception("Coupon have not been activated");
                }
                if (cupMod.AMount <= 0)
                {
                    throw new Exception("Abnormal value of coupon[" + cupMod.AMount.ToString("N") + "]");
                }

                result.flow    = code;
                result.enabled = true;
                switch (cupMod.ZType)
                {
                case "金额":
                {
                    money        -= cupMod.AMount;
                    money         = ((money < 0.0) ? 0.0 : money);
                    result.money  = money;
                    result.amount = cupMod.AMount;
                }
                break;

                case "比率":
                {
                    double amount = Convert.ToDouble((money * cupMod.AMount).ToString("F2"));
                    money        -= amount;
                    money         = ((money < 0.0) ? 0.0 : money);
                    result.money  = money;
                    result.amount = amount;
                }
                break;
                }
            }
            catch (Exception ex) { result.err = ex.Message; result.enabled = false; }
            return(result);
        }
Example #2
0
        public M_Ex_Coupon GetModelFromReader(DbDataReader rdr)
        {
            M_Ex_Coupon model = new M_Ex_Coupon();

            model.ID      = ConvertToInt(rdr["ID"]);
            model.Code    = ConverToStr(rdr["Code"]);
            model.ZType   = ConverToStr(rdr["ZType"]);
            model.ZStatus = ConvertToInt(rdr["ZStatus"]);
            model.AMount  = ConverToDouble(rdr["AMount"]);
            model.Remind  = ConverToStr(rdr["Remind"]);
            model.CDate   = ConvertToDate(rdr["CDate"]);
            rdr.Close();
            return(model);
        }
Example #3
0
        public override SqlParameter[] GetParameters()
        {
            M_Ex_Coupon model = this;

            SqlParameter[] sp = GetSP();
            sp[0].Value = model.ID;
            sp[1].Value = model.Code;
            sp[2].Value = model.ZType;
            sp[3].Value = model.ZStatus;
            sp[4].Value = model.AMount;
            sp[5].Value = model.Remind;
            sp[6].Value = model.CDate;
            return(sp);
        }
Example #4
0
 public bool UpdateByID(M_Ex_Coupon model)
 {
     return(DBCenter.UpdateByID(model, model.ID));
 }
Example #5
0
 public int Insert(M_Ex_Coupon model)
 {
     //return Sql.insert(TbName, model.GetParameters(model), BLLCommon.GetParas(model), BLLCommon.GetFields(model));
     return(DBCenter.Insert(model));
 }