void LoadFee() { decimal HtmlFee = 0M; Ltf.Model.Freight mdl = new Ltf.Model.Freight(); Ltf.BLL.Freight bllf = new Ltf.BLL.Freight(); mdl = bllf.GetModel(1); if (mdl != null) { int typeID = mdl.typID; if (typeID == 1) { HtmlFee = 0; } else if (typeID == 2) { HtmlFee = mdl.Fee; TwoTypeFee = mdl.TotalPrice; } else if (typeID == 3) { HtmlFee = mdl.Fee; } Fee = HtmlFee.ToString(); hideFee.Value = typeID.ToString(); } }
protected void btnSubmit_Click(object sender, EventArgs e) { mod = new Ltf.Model.Freight(); if (RadOne.Checked == true) { mod.typID = int.Parse(RadOne.Text); mod.TotalPrice = decimal.Parse("0"); mod.spec = "0"; mod.Fee = decimal.Parse("0"); } if (RadTwo.Checked == true) { mod.typID = int.Parse(RadTwo.Text); mod.TotalPrice = decimal.Parse(txtTotal.Text.Trim()); mod.spec = txtLow.Text.Trim(); mod.Fee = decimal.Parse(txtFee.Text.Trim()); } if (Rad3.Checked == true) { mod.typID = int.Parse(Rad3.Text); mod.Fee = decimal.Parse(txtMasterFee.Text.Trim()); mod.TotalPrice = decimal.Parse("0"); mod.spec = "0"; } mod.ID = 1; if (bllf.Update(mod)) { JscriptMsg("修改成功!", "Freight.aspx", "Success"); } }
void LoadFee() { Ltf.Model.Freight mdl = new Ltf.Model.Freight(); Ltf.BLL.Freight bllf = new Ltf.BLL.Freight(); mdl = bllf.GetModel(1); if (mdl != null) { HtmlFee = "<span style=\"color: #e53333;\">"; int typeID = mdl.typID; if (typeID == 1) { HtmlFee += "全店免運費"; } else if (typeID == 2) { HtmlFee += mdl.TotalPrice + "元(含)以上免運費," + mdl.spec + "元以下收運費" + mdl.Fee + "元"; } else if (typeID == 3) { HtmlFee += "每筆訂單固定收取運費" + mdl.Fee + "元"; } HtmlFee += "</span>"; } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Ltf.Model.Freight model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Freight set "); strSql.Append("typID=@typID,"); strSql.Append("TotalPrice=@TotalPrice,"); strSql.Append("Fee=@Fee,"); strSql.Append("spec=@spec"); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@typID", SqlDbType.Int, 4), new SqlParameter("@TotalPrice", SqlDbType.Decimal, 9), new SqlParameter("@Fee", SqlDbType.Decimal, 9), new SqlParameter("@spec", SqlDbType.NVarChar, 50), new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = model.typID; parameters[1].Value = model.TotalPrice; parameters[2].Value = model.Fee; parameters[3].Value = model.spec; parameters[4].Value = model.ID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Ltf.Model.Freight model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Freight("); strSql.Append("typID,TotalPrice,Fee,spec)"); strSql.Append(" values ("); strSql.Append("@typID,@TotalPrice,@Fee,@spec)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@typID", SqlDbType.Int, 4), new SqlParameter("@TotalPrice", SqlDbType.Decimal, 9), new SqlParameter("@Fee", SqlDbType.Decimal, 9), new SqlParameter("@spec", SqlDbType.NVarChar, 50) }; parameters[0].Value = model.typID; parameters[1].Value = model.TotalPrice; parameters[2].Value = model.Fee; parameters[3].Value = model.spec; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Ltf.Model.Freight DataRowToModel(DataRow row) { Ltf.Model.Freight model = new Ltf.Model.Freight(); if (row != null) { if (row["ID"] != null && row["ID"].ToString() != "") { model.ID = int.Parse(row["ID"].ToString()); } if (row["typID"] != null && row["typID"].ToString() != "") { model.typID = int.Parse(row["typID"].ToString()); } if (row["TotalPrice"] != null && row["TotalPrice"].ToString() != "") { model.TotalPrice = decimal.Parse(row["TotalPrice"].ToString()); } if (row["Fee"] != null && row["Fee"].ToString() != "") { model.Fee = decimal.Parse(row["Fee"].ToString()); } if (row["spec"] != null) { model.spec = row["spec"].ToString(); } } return(model); }
void LoadData() { mod = bllf.GetModel(1); if (mod.typID == 1) { RadOne.Checked = true; } if (mod.typID == 2) { RadTwo.Checked = true; txtTotal.Text = mod.TotalPrice.ToString(); txtLow.Text = mod.spec.ToString(); txtFee.Text = mod.Fee.ToString(); } if (mod.typID == 3) { Rad3.Checked = true; txtMasterFee.Text = mod.Fee.ToString(); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Ltf.Model.Freight GetModel(int ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ID,typID,TotalPrice,Fee,spec from Freight "); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = ID; Ltf.Model.Freight model = new Ltf.Model.Freight(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }