Ejemplo n.º 1
0
        protected override void btnSave_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtHits.Text.Trim())) txtHits.Text = "0";

            DateTime dt;
            if (!DateTime.TryParse(txtTime.Text.Trim(), out dt))
            {
                dt = DateTime.Now;
            }

            if (action.Equals("add"))
            {
                news = new cmsNews();

                news.RGuid = Guid.NewGuid().ToString();
                news.AddUser = LoginUser.Id;
                news.AddTime = DateTime.Now;

                news.IsIndex = 0;
                news.IsTop = 0;
            }
            else
            {
                news = ns.GetModel(id);
                news.Attach();
            }
            news.NodeCode = ddlCatalog.SelectedValue;
            news.Title = txtTitle.Text.Trim();
            news.Content = txtContent.Text.Trim();
            news.Summary = txtSummary.Text.Trim();
            news.Tags = txtTags.Text.Trim();
            news.SmallPic = hidImages1.Value;
            news.ProductNo = txtProductNo.Text;
            news.ProductModel = txtModel.Text;
            news.Parameter1 = txtParameter1.Text;
            news.Parameter2 = txtParameter2.Text;
            news.Parameter3 = txtParameter3.Text;
            news.Parameter4 = txtParameter4.Text;
            news.Parameter5 = txtParameter5.Text;
            news.Parameter6 = txtParameter6.Text;
            news.Parameter7 = txtParameter7.Text;
            news.Parameter8 = txtParameter8.Text;
            news.Parameter9 = txtParameter9.Text;
            news.Pics = hidImages2.Value;
            news.Author = txtAuthor.Text;
            news.Source = txtSource.Text;
            news.Hits = Convert.ToInt32(txtHits.Text);
            news.OrderNo = 0;
            news.EditUser = LoginUser.Id;
            news.EditTime = dt;
            news.IsAudit = 0;
            if (true)//WebConfig.NoAudit
            {
                news.IsAudit = 1;
                news.AuditUser = LoginUser.Id;
                news.AuditTime = DateTime.Now;
                news.IsIndex = 1;
            }
            news.LangId = CurrentLanguageId;
            List<int> ztList = new List<int>();
            foreach (ListItem item in cblZt.Items)
            {
                if (item.Selected)
                {
                    ztList.Add(Convert.ToInt32(item.Value));
                }
            }
            try
            {
                int r = ns.Save(news);

                ntrs.Save(news.RGuid, ztList.ToArray());

                if (action.Equals("add"))
                {

                    ScriptUtil.ConfirmAndRedirect(@"产品添加成功!\n“确定”继续添加,“取消”则跳转到列表页。", "ProductAdd.aspx?node=" + NodeCode, "ProductList.aspx?node=" + NodeCode);
                }
                else
                {
                    ScriptUtil.ConfirmAndRedirect(@"产品修改成功!\n“确定”留在本页,“取消”则跳转到列表页。", "ProductAdd.aspx?node=" + NodeCode + "&id=" + id + "&action=edit", "ProductList.aspx?node=" + NodeCode);
                }

            }
            catch (Exception ex)
            {
                ScriptUtil.Alert(ex.Message);

                Logger.Error(ex.Message);
            }
        }