Example #1
0
        protected override void btnSave_Click(object sender, EventArgs e)
        {
            long lngId = long.Parse(ddlLanguage.SelectedValue);

            if (lngId == 0)
            {
                ScriptUtil.Alert("请先选择所属语言");
                return;
            }
            if (action.Equals("add"))
            {
                if (cs.Exists(lngId))
                {
                    ScriptUtil.Alert("该语言下已有公司信息不能再次添加");
                    return;
                }
                com = new cmsCompany();
            }
            else
            {
                com = cs.GetModel(id);
                com.Attach();
            }

            com.LangId     = lngId;
            com.ComName    = txtName.Text;
            com.ComAddr    = txtAddr.Text;
            com.ComZipcode = txtZipCode.Text;
            com.ComTel     = txtTel.Text;
            com.ComFax     = txtFax.Text;
            com.ComEmail   = txtEmail.Text;
            com.ComUrl     = txtUrl.Text;
            com.Summary    = txtSummary.Text;
            try
            {
                long r = cs.SaveModel(com);
                if (action.Equals("edit"))
                {
                    r = com.Id;
                }
                hidID.Value = r.ToString();
                if (action.Equals("add"))
                {
                    ScriptUtil.ConfirmAndRedirect(@"公司信息添加成功!\n“确定”继续添加,“取消”则跳转到列表页。", "CompanyAdd.aspx?node=" + NodeCode, "CompanyList.aspx?node=" + NodeCode);
                }
                else
                {
                    ScriptUtil.ConfirmAndRedirect(@"公司信息修改成功!\n“确定”留在本页,“取消”则跳转到列表页。", "CompanyAdd.aspx?node=" + NodeCode + "&id=" + id, "CompanyList.aspx?node=" + NodeCode);
                }
            }
            catch (Exception ex)
            {
                ScriptUtil.Alert(ex.Message);

                Logger.Error(ex.Message);
            }
        }
Example #2
0
        protected override void btnSave_Click(object sender, EventArgs e)
        {
            long lngId = long.Parse(ddlLanguage.SelectedValue);

            if (lngId == 0)
            {
                ScriptUtil.Alert("请先设置语言");
                return;
            }

            com = cs.GetModel(hidID.Value);
            if (com != null)
            {
                com.Attach();
            }
            else
            {
                com = new cmsCompany();
            }

            com.LangId     = lngId;
            com.ComName    = txtName.Text;
            com.ComAddr    = txtAddr.Text;
            com.ComZipcode = txtZipCode.Text;
            com.ComTel     = txtTel.Text;
            com.ComFax     = txtFax.Text;
            com.ComEmail   = txtEmail.Text;
            com.ComUrl     = txtUrl.Text;
            com.Summary    = txtSummary.Text;
            try
            {
                long r = cs.SaveModel(com);
                hidID.Value = r.ToString();

                ScriptUtil.Alert(@"公司信息保存成功!");
            }
            catch (Exception ex)
            {
                ScriptUtil.Alert(ex.Message);

                Logger.Error(ex.Message);
            }
        }