Esempio n. 1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            Maticsoft.Model.Settings.AdvertisePosition model = new Maticsoft.Model.Settings.AdvertisePosition();
            if (this.txtAdvPositionName.Text.Trim().Length == 0)
            {
                MessageBox.ShowFailTip(this, "广告位名称不能为空!");
            }
            else
            {
                string selectedValue = this.ddlShowType.SelectedValue;
                switch (selectedValue)
                {
                    case "1":
                        if (!PageValidate.IsNumber(this.txtRepeatColumns.Text))
                        {
                            MessageBox.ShowFailTip(this, "请数如正确的横向平铺时行显示个数!");
                            return;
                        }
                        model.RepeatColumns = new int?(Globals.SafeInt(this.txtRepeatColumns.Text, 0));
                        break;

                    case "4":
                        if (string.IsNullOrWhiteSpace(this.txtAdvHtml.Text))
                        {
                            MessageBox.ShowFailTip(this, "请数广告位内容!");
                            return;
                        }
                        model.AdvHtml = this.txtAdvHtml.Text.Trim();
                        break;
                }
                model.Width = new int?(Globals.SafeInt(this.txtWidth.Text, 0));
                model.Height = new int?(Globals.SafeInt(this.txtHeight.Text, 0));
                if (this.chkIsOne.Checked)
                {
                    if (!PageValidate.IsNumber(this.txtTimeInterval.Text))
                    {
                        MessageBox.ShowFailTip(this, "请输入正确的循环广告时间间隔!");
                        return;
                    }
                    model.IsOne = true;
                    model.TimeInterval = new int?(Globals.SafeInt(this.txtTimeInterval.Text, 0));
                }
                else
                {
                    model.IsOne = false;
                }
                model.ShowType = new int?(Globals.SafeInt(selectedValue, -1));
                model.AdvPositionName = this.txtAdvPositionName.Text.Trim();
                model.CreatedDate = new DateTime?(DateTime.Now);
                model.CreatedUserID = new int?(base.CurrentUser.UserID);
                Maticsoft.BLL.Settings.AdvertisePosition position2 = new Maticsoft.BLL.Settings.AdvertisePosition();
                int num = 0;
                if (selectedValue == "4")
                {
                    num = position2.Add(model);
                    Maticsoft.BLL.Settings.Advertisement advertisement = new Maticsoft.BLL.Settings.Advertisement();
                    Maticsoft.Model.Settings.Advertisement advertisement2 = new Maticsoft.Model.Settings.Advertisement {
                        AdvertisementName = "自定义广告代码",
                        ContentType = 3,
                        AdvPositionId = new int?(num),
                        CreatedDate = new DateTime?(DateTime.Now)
                    };
                    advertisement.Add(advertisement2);
                }
                else
                {
                    num = position2.Add(model);
                }
                if (num > 0)
                {
                    MessageBox.ResponseScript(this, "parent.location.href='List.aspx'");
                }
                else
                {
                    MessageBox.ShowFailTip(this, "网络异常,请稍后再试");
                }
            }
        }
Esempio n. 2
0
 public Maticsoft.Model.Settings.AdvertisePosition GetModel(int AdvPositionId)
 {
     StringBuilder builder = new StringBuilder();
     builder.Append("SELECT  TOP 1 * FROM AD_AdvertisePosition ");
     builder.Append(" WHERE AdvPositionId=@AdvPositionId");
     SqlParameter[] cmdParms = new SqlParameter[] { new SqlParameter("@AdvPositionId", SqlDbType.Int, 4) };
     cmdParms[0].Value = AdvPositionId;
     Maticsoft.Model.Settings.AdvertisePosition position = new Maticsoft.Model.Settings.AdvertisePosition();
     DataSet set = DbHelperSQL.Query(builder.ToString(), cmdParms);
     if (set.Tables[0].Rows.Count <= 0)
     {
         return null;
     }
     if ((set.Tables[0].Rows[0]["AdvPositionId"] != null) && (set.Tables[0].Rows[0]["AdvPositionId"].ToString() != ""))
     {
         position.AdvPositionId = int.Parse(set.Tables[0].Rows[0]["AdvPositionId"].ToString());
     }
     if ((set.Tables[0].Rows[0]["AdvPositionName"] != null) && (set.Tables[0].Rows[0]["AdvPositionName"].ToString() != ""))
     {
         position.AdvPositionName = set.Tables[0].Rows[0]["AdvPositionName"].ToString();
     }
     if ((set.Tables[0].Rows[0]["ShowType"] != null) && (set.Tables[0].Rows[0]["ShowType"].ToString() != ""))
     {
         position.ShowType = new int?(int.Parse(set.Tables[0].Rows[0]["ShowType"].ToString()));
     }
     if ((set.Tables[0].Rows[0]["RepeatColumns"] != null) && (set.Tables[0].Rows[0]["RepeatColumns"].ToString() != ""))
     {
         position.RepeatColumns = new int?(int.Parse(set.Tables[0].Rows[0]["RepeatColumns"].ToString()));
     }
     if ((set.Tables[0].Rows[0]["Width"] != null) && (set.Tables[0].Rows[0]["Width"].ToString() != ""))
     {
         position.Width = new int?(int.Parse(set.Tables[0].Rows[0]["Width"].ToString()));
     }
     if ((set.Tables[0].Rows[0]["Height"] != null) && (set.Tables[0].Rows[0]["Height"].ToString() != ""))
     {
         position.Height = new int?(int.Parse(set.Tables[0].Rows[0]["Height"].ToString()));
     }
     if ((set.Tables[0].Rows[0]["AdvHtml"] != null) && (set.Tables[0].Rows[0]["AdvHtml"].ToString() != ""))
     {
         position.AdvHtml = set.Tables[0].Rows[0]["AdvHtml"].ToString();
     }
     if ((set.Tables[0].Rows[0]["IsOne"] != null) && (set.Tables[0].Rows[0]["IsOne"].ToString() != ""))
     {
         if ((set.Tables[0].Rows[0]["IsOne"].ToString() == "1") || (set.Tables[0].Rows[0]["IsOne"].ToString().ToLower() == "true"))
         {
             position.IsOne = true;
         }
         else
         {
             position.IsOne = false;
         }
     }
     if ((set.Tables[0].Rows[0]["TimeInterval"] != null) && (set.Tables[0].Rows[0]["TimeInterval"].ToString() != ""))
     {
         position.TimeInterval = new int?(int.Parse(set.Tables[0].Rows[0]["TimeInterval"].ToString()));
     }
     if ((set.Tables[0].Rows[0]["CreatedDate"] != null) && (set.Tables[0].Rows[0]["CreatedDate"].ToString() != ""))
     {
         position.CreatedDate = new DateTime?(DateTime.Parse(set.Tables[0].Rows[0]["CreatedDate"].ToString()));
     }
     if ((set.Tables[0].Rows[0]["CreatedUserID"] != null) && (set.Tables[0].Rows[0]["CreatedUserID"].ToString() != ""))
     {
         position.CreatedUserID = new int?(int.Parse(set.Tables[0].Rows[0]["CreatedUserID"].ToString()));
     }
     return position;
 }
Esempio n. 3
0
 public List<Maticsoft.Model.Settings.AdvertisePosition> DataTableToList(DataTable dt)
 {
     List<Maticsoft.Model.Settings.AdvertisePosition> list = new List<Maticsoft.Model.Settings.AdvertisePosition>();
     int count = dt.Rows.Count;
     if (count > 0)
     {
         for (int i = 0; i < count; i++)
         {
             Maticsoft.Model.Settings.AdvertisePosition item = new Maticsoft.Model.Settings.AdvertisePosition();
             if ((dt.Rows[i]["AdvPositionId"] != null) && (dt.Rows[i]["AdvPositionId"].ToString() != ""))
             {
                 item.AdvPositionId = int.Parse(dt.Rows[i]["AdvPositionId"].ToString());
             }
             if ((dt.Rows[i]["AdvPositionName"] != null) && (dt.Rows[i]["AdvPositionName"].ToString() != ""))
             {
                 item.AdvPositionName = dt.Rows[i]["AdvPositionName"].ToString();
             }
             if ((dt.Rows[i]["ShowType"] != null) && (dt.Rows[i]["ShowType"].ToString() != ""))
             {
                 item.ShowType = new int?(int.Parse(dt.Rows[i]["ShowType"].ToString()));
             }
             if ((dt.Rows[i]["RepeatColumns"] != null) && (dt.Rows[i]["RepeatColumns"].ToString() != ""))
             {
                 item.RepeatColumns = new int?(int.Parse(dt.Rows[i]["RepeatColumns"].ToString()));
             }
             if ((dt.Rows[i]["Width"] != null) && (dt.Rows[i]["Width"].ToString() != ""))
             {
                 item.Width = new int?(int.Parse(dt.Rows[i]["Width"].ToString()));
             }
             if ((dt.Rows[i]["Height"] != null) && (dt.Rows[i]["Height"].ToString() != ""))
             {
                 item.Height = new int?(int.Parse(dt.Rows[i]["Height"].ToString()));
             }
             if ((dt.Rows[i]["AdvHtml"] != null) && (dt.Rows[i]["AdvHtml"].ToString() != ""))
             {
                 item.AdvHtml = dt.Rows[i]["AdvHtml"].ToString();
             }
             if ((dt.Rows[i]["IsOne"] != null) && (dt.Rows[i]["IsOne"].ToString() != ""))
             {
                 if ((dt.Rows[i]["IsOne"].ToString() == "1") || (dt.Rows[i]["IsOne"].ToString().ToLower() == "true"))
                 {
                     item.IsOne = true;
                 }
                 else
                 {
                     item.IsOne = false;
                 }
             }
             if ((dt.Rows[i]["TimeInterval"] != null) && (dt.Rows[i]["TimeInterval"].ToString() != ""))
             {
                 item.TimeInterval = new int?(int.Parse(dt.Rows[i]["TimeInterval"].ToString()));
             }
             if ((dt.Rows[i]["CreatedDate"] != null) && (dt.Rows[i]["CreatedDate"].ToString() != ""))
             {
                 item.CreatedDate = new DateTime?(DateTime.Parse(dt.Rows[i]["CreatedDate"].ToString()));
             }
             if ((dt.Rows[i]["CreatedUserID"] != null) && (dt.Rows[i]["CreatedUserID"].ToString() != ""))
             {
                 item.CreatedUserID = new int?(int.Parse(dt.Rows[i]["CreatedUserID"].ToString()));
             }
             list.Add(item);
         }
     }
     return list;
 }
Esempio n. 4
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            Maticsoft.Model.Settings.AdvertisePosition model = new Maticsoft.Model.Settings.AdvertisePosition();
            int num = int.Parse(this.lblAdvPositionId.Text);
            model.AdvHtml = string.Empty;
            if (this.txtAdvPositionName.Text.Trim().Length == 0)
            {
                MessageBox.ShowFailTip(this, "广告位名称不能为空!");
            }
            else
            {
                string selectedValue = this.ddlShowType.SelectedValue;
                switch (selectedValue)
                {
                    case "1":
                        if (!PageValidate.IsNumber(this.txtRepeatColumns.Text))
                        {
                            MessageBox.ShowFailTip(this, "请数如正确的横向平铺时行显示个数!");
                            return;
                        }
                        model.RepeatColumns = new int?(Globals.SafeInt(this.txtRepeatColumns.Text, 0));
                        break;

                    case "4":
                        if (string.IsNullOrWhiteSpace(this.txtAdvHtml.Text))
                        {
                            MessageBox.ShowFailTip(this, "请数广告位内容!");
                            return;
                        }
                        model.AdvHtml = this.txtAdvHtml.Text.Trim();
                        break;
                }
                if (!PageValidate.IsNumber(this.txtWidth.Text) || !PageValidate.IsNumber(this.txtHeight.Text))
                {
                    MessageBox.ShowFailTip(this, "请设置此广告位里面广告内容的宽、高,单位为像素(px)!");
                }
                else
                {
                    model.Width = new int?(Globals.SafeInt(this.txtWidth.Text, 0));
                    model.Height = new int?(Globals.SafeInt(this.txtHeight.Text, 0));
                    if (this.chkIsOne.Checked)
                    {
                        if (!PageValidate.IsNumber(this.txtTimeInterval.Text))
                        {
                            MessageBox.ShowFailTip(this, "请输入正确的循环广告时间间隔!");
                            return;
                        }
                        model.IsOne = true;
                        model.TimeInterval = new int?(Globals.SafeInt(this.txtTimeInterval.Text, 0));
                    }
                    else
                    {
                        model.IsOne = false;
                    }
                    model.AdvPositionId = num;
                    model.ShowType = new int?(Globals.SafeInt(selectedValue, -1));
                    model.AdvPositionName = this.txtAdvPositionName.Text.Trim();
                    model.CreatedDate = new DateTime?(DateTime.Now);
                    model.CreatedUserID = new int?(base.CurrentUser.UserID);
                    Maticsoft.BLL.Settings.AdvertisePosition position2 = new Maticsoft.BLL.Settings.AdvertisePosition();
                    if (position2.Update(model))
                    {
                        MessageBox.ResponseScript(this, "parent.location.href='List.aspx'");
                    }
                    else
                    {
                        MessageBox.ShowFailTip(this, "网络异常,请稍后再试!");
                    }
                }
            }
        }