private void ShowInfo(int _id) { BLL.sales bll = new BLL.sales(); Model.sales model = bll.GetModel(_id); txtTitle.Text = model.title; txtSubTitle.Text = model.sub_title; txtImgUrl.Text = model.img_url; ddlType.SelectedValue = model.type; txtStartTime.Text = model.start_time.ToString("yyyy-M-d"); if (model.end_time != null) { txtEndTime.Text = model.end_time.GetValueOrDefault().ToString("yyyy-M-d"); } txtSortId.Text = model.sort_id.ToString(); cbStatus.Checked = (model.status == 1); txtZhaiyao.Text = model.summary; txtContent.Value = model.content; rptGroup.DataSource = Tea.DBUtility.DbHelperSQL.Query("select * from view_goods where yu_lock=" + id + ""); rptGroup.DataBind(); }
private bool DoEdit(int _id) { bool result = false; BLL.sales bll = new BLL.sales(); Model.sales model = bll.GetModel(_id); string type = ddlType.SelectedValue.Trim(); model.title = txtTitle.Text.Trim(); model.sub_title = txtSubTitle.Text.Trim(); model.img_url = txtImgUrl.Text; model.type = type; model.start_time = Utils.StrToDateTime(txtStartTime.Text.Trim()); DateTime _end_time; if (DateTime.TryParse(txtEndTime.Text.Trim(), out _end_time)) { model.end_time = _end_time; } if (cbStatus.Checked) { model.status = 1; } else { model.status = 0; } model.sort_id = Utils.StrToInt(txtSortId.Text.Trim(), 99); //內容摘要提取內容前255個字元 if (string.IsNullOrEmpty(txtZhaiyao.Text.Trim())) { model.summary = Utils.DropHTML(txtContent.Value, 255); } else { model.summary = Utils.DropHTML(txtZhaiyao.Text, 255); } model.content = txtContent.Value; System.Text.StringBuilder sb = new System.Text.StringBuilder(); foreach (ListItem li in cblItem.Items) { if (li.Selected) { sb.AppendFormat("{0},", li.Value); } } #region 促銷組合============== StringBuilder idListA = new StringBuilder(); string[] parentid = Request.Form.GetValues("goods_id"); string[] newprice = Request.Form.GetValues("new_price"); if (parentid != null && parentid.Length > 0 && newprice != null && newprice.Length > 0) { for (int i = 0; i < parentid.Length; i++) { new Tea.BLL.goods().UpdateField(int.Parse(parentid[i].ToString()), "yu_lock=" + id + ",yu_num=" + newprice[i].ToString() + ""); idListA.Append(parentid[i].ToString() + ","); } } string id_listA = Utils.DelLastChar(idListA.ToString(), ","); if (!string.IsNullOrEmpty(id_listA)) { Tea.DBUtility.DbHelperSQL.ExecuteSql("update shop_goods set yu_lock=0,yu_num=0 where yu_lock=" + model.id + " and id not in(select id from shop_goods where id in(" + id_listA + "))"); } else { Tea.DBUtility.DbHelperSQL.ExecuteSql("update shop_goods set yu_lock=0,yu_num=0 where yu_lock=" + model.id + ""); } #endregion if (bll.Update(model)) { AddAdminLog(TWEnums.ActionEnum.Edit.ToString(), "修改銷售活動:" + model.title); //記錄日誌 result = true; } return(result); }
private bool DoEdit(int _id) { bool result = false; BLL.sales bll = new BLL.sales(); Model.sales model = bll.GetModel(_id); string type = ddlType.SelectedValue.Trim(); model.title = txtTitle.Text.Trim(); model.sub_title = txtSubTitle.Text.Trim(); model.img_url = txtImgUrl.Text; model.company = Utils.StrToInt(company.SelectedValue, 1); model.type = type; model.start_time = Utils.StrToDateTime(txtStartTime.Text.Trim()); DateTime _end_time; if (DateTime.TryParse(txtEndTime.Text.Trim(), out _end_time)) { model.end_time = _end_time; } if (cbStatus.Checked) { model.status = 1; } else { model.status = 0; } model.sort_id = Utils.StrToInt(txtSortId.Text.Trim(), 99); //內容摘要提取內容前255個字元 if (string.IsNullOrEmpty(txtZhaiyao.Text.Trim())) { model.summary = Utils.DropHTML(txtContent.Value, 255); } else { model.summary = Utils.DropHTML(txtZhaiyao.Text, 255); } model.content = txtContent.Value; #region 促銷組合============== StringBuilder idListA = new StringBuilder(); string[] parentid = Request.Form.GetValues("goods_id"); if (parentid != null && parentid.Length > 0) { for (int i = 0; i < parentid.Length; i++) { new Tea.BLL.goods().UpdateField(int.Parse(parentid[i].ToString()), "yu_lock=" + id + ""); idListA.Append(parentid[i].ToString() + ","); } } string id_listA = Utils.DelLastChar(idListA.ToString(), ","); if (!string.IsNullOrEmpty(id_listA)) { Tea.DBUtility.DbHelperSQL.ExecuteSql("update shop_goods set yu_lock=0 where yu_lock=" + model.id + " and id not in(select id from shop_goods where id in(" + id_listA + "))"); } else { Tea.DBUtility.DbHelperSQL.ExecuteSql("update shop_goods set yu_lock=0 where yu_lock=" + model.id + ""); } #endregion #region 減折============== StringBuilder idList1 = new StringBuilder(); string[] item1id = Request.Form.GetValues("item1_id"); string[] zhe1moeny = Request.Form.GetValues("zhe1_moeny"); string[] zhe1num = Request.Form.GetValues("zhe1_num"); if (zhe1moeny != null && zhe1moeny.Length > 0 && zhe1num != null && zhe1num.Length > 0) { for (int i = 0; i < zhe1moeny.Length; i++) { try { Model.goods_sales model_list = null; int id = int.Parse(item1id[i].ToString()); bool update = true; if (id == 0) { model_list = new Model.goods_sales(); update = false; } else { model_list = bll_list.GetModel(id); } model_list.main_id = model.id; model_list.parent_id = int.Parse(zhe1moeny[i].ToString()); model_list.goods_id = int.Parse(zhe1num[i].ToString()); if (update) { bll_list.Update(model_list); idList1.Append(model_list.id + ","); } else { int a = bll_list.Add(model_list); idList1.Append(a + ","); } } catch (Exception eee) { } } } string id_list1 = Utils.DelLastChar(idList1.ToString(), ","); if (!string.IsNullOrEmpty(id_list1)) { Tea.DBUtility.DbHelperSQL.ExecuteSql("delete from shop_goods_sales where main_id=" + model.id + " and id not in(select id from shop_goods_sales where id in(" + id_list1 + "))"); } else { Tea.DBUtility.DbHelperSQL.ExecuteSql("delete from shop_goods_sales where main_id=" + model.id + ""); } #endregion if (bll.Update(model)) { AddAdminLog(TWEnums.ActionEnum.Edit.ToString(), "修改銷售活動:" + model.title); //記錄日誌 result = true; } return(result); }