Beispiel #1
0
 private void pnlOK_Click(object sender, EventArgs e)
 {
     try
     {
         if (ad_id.Length == 0)
         {
             ad            = new Model.ad();
             ad.ad_type    = 0;
             ad.ad_name    = txt_name.Text;
             ad.ad_text    = txt_ad_text.Text;
             ad.goods_ids  = txt_goods_nos.Text;
             ad.title_img  = pnlimgA.Text;
             ad.detail_img = pnlimgC1.Text + "," + pnlimgC2.Text + "," + pnlimgC3.Text + "," + pnlimgC4.Text + "," + pnlimgC5.Text + "," + pnlimgC6.Text;
             bll.Add(ad);
             Program.frmMsg("新增成功!");
             this.Close();
         }
         else
         {
             ad.ad_name    = txt_name.Text;
             ad.ad_text    = txt_ad_text.Text;
             ad.goods_ids  = txt_goods_nos.Text;
             ad.title_img  = pnlimgA.Text;
             ad.detail_img = pnlimgC1.Text + "," + pnlimgC2.Text + "," + pnlimgC3.Text + "," + pnlimgC4.Text + "," + pnlimgC5.Text + "," + pnlimgC6.Text;
             bll.Change(ad);
             Program.frmMsg("修改成功!");
             this.Close();
         }
     }
     catch (Exception ex)
     {
         Program.frmMsg(ex.Message);
     }
 }
Beispiel #2
0
        List <Model.ad> IAd.GetList(int pageSize, int pageIndex, out int total)
        {
            var req  = new Request();
            var json = req.request("/ad?t=get_list", "{\"pageSize\":\"" + pageSize + "\",\"pageIndex\":\"" + pageIndex + "\"}");

            ReadWriteContext.IReadContext read = new ReadWriteContext.ReadContextByJson(json);
            if (read.Read("errId") != "0")
            {
                throw new Exception(read.Read("errMsg"));
            }
            //
            total = Conv.ToInt(read.Read("total"));
            //
            var lst = new List <Model.ad>();

            if (read.Read("datas") != "")
            {
                foreach (ReadWriteContext.IReadContext r in read.ReadList("datas"))
                {
                    var item = new Model.ad();
                    lst.Add(item);
                    item.ad_id      = r.Read("ad_id");
                    item.ad_type    = Conv.ToInt(r.Read("ad_type"));
                    item.ad_name    = r.Read("ad_name");
                    item.title_img  = r.Read("title_img");
                    item.detail_img = r.Read("detail_img");
                    item.ad_text    = r.Read("ad_text");
                    item.goods_ids  = r.Read("goods_ids");
                }
            }
            return(lst);
        }
Beispiel #3
0
 public AdEdit(string ad_id)
 {
     InitializeComponent();
     GlobalData.InitForm(this);
     this.ad_id              = ad_id;
     ad                      = bll.Select(ad_id);
     txt_ad_text.Text        = ad.ad_text;
     txt_name.Text           = ad.ad_name;
     txt_goods_nos.Text      = ad.goods_ids;
     pnlimgA.Text            = ad.title_img;
     pnlimgA.BackgroundImage = bllg.getImage(AppSetting.imgsvr + ad.title_img);
     string[] arr = ad.detail_img.Split(',', ',');
     if (arr.Length >= 1)
     {
         pnlimgC1.Text            = arr[0];
         pnlimgC1.BackgroundImage = bllg.getImage(AppSetting.imgsvr + arr[0]);
         string url = AppSetting.imgsvr + arr[0];
     }
     if (arr.Length >= 2)
     {
         pnlimgC2.Text            = arr[1];
         pnlimgC2.BackgroundImage = bllg.getImage(AppSetting.imgsvr + arr[1]);
     }
     if (arr.Length >= 3)
     {
         pnlimgC3.Text            = arr[2];
         pnlimgC3.BackgroundImage = bllg.getImage(AppSetting.imgsvr + arr[2]);
     }
     if (arr.Length >= 4)
     {
         pnlimgC4.Text            = arr[3];
         pnlimgC4.BackgroundImage = bllg.getImage(AppSetting.imgsvr + arr[3]);
     }
     if (arr.Length >= 5)
     {
         pnlimgC5.Text            = arr[4];
         pnlimgC5.BackgroundImage = bllg.getImage(AppSetting.imgsvr + arr[4]);
     }
     if (arr.Length >= 6)
     {
         pnlimgC6.Text            = arr[5];
         pnlimgC6.BackgroundImage = bllg.getImage(AppSetting.imgsvr + arr[5]);
     }
 }
Beispiel #4
0
        void IAd.Change(Model.ad ad)
        {
            var req = new Request();

            ReadWriteContext.IWriteContext write = new ReadWriteContext.WriteContextByJson();
            write.Append("ad_id", ad.ad_id);
            write.Append("ad_name", ad.ad_name);
            write.Append("title_img", ad.title_img);
            write.Append("detail_img", ad.detail_img);
            write.Append("ad_text", ad.ad_text);
            write.Append("goods_ids", ad.goods_ids);
            var json = req.request("/ad?t=change", write.ToString());

            ReadWriteContext.IReadContext read = new ReadWriteContext.ReadContextByJson(json);
            if (read.Read("errId") != "0")
            {
                throw new Exception(read.Read("errMsg"));
            }
        }
Beispiel #5
0
        Model.ad IAd.Select(string ad_id)
        {
            var req = new Request();

            ReadWriteContext.IWriteContext write = new ReadWriteContext.WriteContextByJson();
            write.Append("ad_id", ad_id);
            var json = req.request("/ad?t=select", write.ToString());

            ReadWriteContext.IReadContext read = new ReadWriteContext.ReadContextByJson(json);
            if (read.Read("errId") != "0")
            {
                throw new Exception(read.Read("errMsg"));
            }
            var ad = new Model.ad();

            ad.ad_id      = read.Read("ad_id");
            ad.ad_type    = Conv.ToInt(read.Read("ad_type"));
            ad.ad_name    = read.Read("ad_name");
            ad.title_img  = read.Read("title_img");
            ad.detail_img = read.Read("detail_img");
            ad.ad_text    = read.Read("ad_text");
            ad.goods_ids  = read.Read("goods_ids");
            return(ad);
        }
Beispiel #6
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtTitle.Text.Trim().Length == 0)
            {
                strErr += "广告名称不能为空!\\n";
            }
            if (!PageValidate.IsDateTime(txtStartDate.Text))
            {
                strErr += "时间格式不正确!\\n";
            }
            if (!PageValidate.IsDateTime(txtEndDate.Text))
            {
                strErr += "时间格式不正确!\\n";
            }
            if (!PageValidate.IsNumber(txtOrders.Text))
            {
                strErr += "排序必须为数字!\\n";
            }
            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            string   title     = txtTitle.Text;
            string   url       = txtUrl.Text;
            DateTime startDate = DateTime.Parse(txtStartDate.Text);
            DateTime endDate   = DateTime.Parse(txtEndDate.Text);
            int      orders    = int.Parse(txtOrders.Text);
            string   pic       = imgPic.ImageUrl;
            string   remark    = txtRemark.Text;

            if (flPic.HasFile)
            {
                string result = Common.CommonHelper.Imageupload(flPic, "ad");
                if (result.IndexOf('|') > 0)
                {
                    pic = result.Split('|')[2];
                }
                else
                {
                    MessageBox.Show(this, result);
                    return;
                }
            }

            hm.BLL.ad bll   = new hm.BLL.ad();
            Model.ad  model = bll.GetModel(int.Parse(lblId.Text));
            model.apId      = int.Parse(ddlAp.SelectedValue);
            model.title     = title;
            model.url       = txtUrl.Text;
            model.pic       = pic;
            model.startDate = startDate;
            model.endDate   = endDate;
            model.remark    = remark;
            model.orders    = orders;

            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }