/// <summary> /// 提交事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnOK_Click(object sender, EventArgs e) { bool flag = SetValueProductSexTypeModel(); if (flag) { if ((int)ViewState["ID"] == 1) { //获取指定产品适用人群的行数 int getCount = SetParametersBLL.GetProductSexTypeCountByName(txtProductSexTypeName.Text.Trim()); if (getCount > 0) { Page.ClientScript.RegisterStartupScript(GetType(), "", Transforms.ReturnAlert(GetTran("002226", "该适用人群已经存在!"))); } else { //添加适用人群信息 using (SqlConnection conn = new SqlConnection(DBHelper.connString)) { int id; conn.Open(); using (SqlTransaction tran = conn.BeginTransaction()) { try { SetParametersBLL.AddProductSexType(tran, productSexTypeModel, out id); language.AddNewTranslationRecord(tran, "ProductSexType", "ProductSexTypeName", id, txtProductSexTypeName.Text.Trim(), txtProductSexTypeName.Text.Trim()); language.AddNewTranslationRecord(tran, "ProductSexType", "ProductSexTypeDescr", id, txtProductSexTypeDescr.Text.Trim(), txtProductSexTypeDescr.Text.Trim()); tran.Commit(); } catch { tran.Rollback(); Page.ClientScript.RegisterStartupScript(GetType(), "", Transforms.ReturnAlert(GetTran("002229", "添加适用人群失败,请联系管理员!"))); return; } Page.ClientScript.RegisterStartupScript(GetType(), "", Transforms.ReturnAlert(GetTran("002227", "添加适用人群成功!"))); divProductSexType.Visible = false; } } } } if ((int)ViewState["ID"] == 2) { ///获取指定产品适用人群的行数 int getCount = SetParametersBLL.GetProductSexTypeCountByIDName(Convert.ToInt32(ViewState["ProductSexTypeID"]), txtProductSexTypeName.Text.Trim()); if (getCount > 0) { Page.ClientScript.RegisterStartupScript(GetType(), "", Transforms.ReturnAlert(GetTran("002226", "该适用人群已经存在!"))); return; } else { BLL.CommonClass.ChangeLogs cl_h_info = new BLL.CommonClass.ChangeLogs("ProductSexType", "ProductSexTypeID"); cl_h_info.AddRecord(productSexTypeModel.ProductSexTypeID); ///修改指定产品适用人群信息 int updCount = SetParametersBLL.UpdProductSexTypeByID(productSexTypeModel); if (updCount > 0) { cl_h_info.AddRecord(productSexTypeModel.ProductSexTypeID); cl_h_info.ModifiedIntoLogs(ChangeCategory.company28, Session["Company"].ToString(), ENUM_USERTYPE.objecttype9); Page.ClientScript.RegisterStartupScript(GetType(), "", Transforms.ReturnAlert(GetTran("002230", "修改适用人群成功!"))); divProductSexType.Visible = false; } else { Page.ClientScript.RegisterStartupScript(GetType(), "", Transforms.ReturnAlert(GetTran("002231", "修改适用人群失败,请联系管理员!"))); } } } DataBindProductSexType(); } else { return; } }
/// <summary> /// 提交事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnOK_Click(object sender, EventArgs e) { int value = 0; bool flag = SetValueProductColorModel(); if (flag) { if ((int)ViewState["ID"] == 1) { //获取指定产品颜色的行数 int getCount = SetParametersBLL.GetProductColorCountByName(txtProductColorName.Text.Trim()); if (getCount > 0) { Page.ClientScript.RegisterStartupScript(GetType(), "", Transforms.ReturnAlert(GetTran("002201", "该颜色已经存在!"))); } else { //添加颜色信息 using (SqlConnection conn = new SqlConnection(DBHelper.connString)) { int id; conn.Open(); try { value = SetParametersBLL.AddProductColor(productColorModel, out id); language.AddNewTranslationRecord("ProductColor", "ProductColorName", id, txtProductColorName.Text.Trim(), txtProductColorName.Text.Trim()); language.AddNewTranslationRecord("ProductColor", "ProductColorDescr", id, txtProductColorDescr.Text.Trim(), txtProductColorDescr.Text.Trim()); } catch (Exception ex) { value = 0; Page.ClientScript.RegisterStartupScript(GetType(), "", Transforms.ReturnAlert(GetTran("002203", "添加颜色失败,请联系管理员!"))); } if (value > 0) { Page.ClientScript.RegisterStartupScript(GetType(), "", Transforms.ReturnAlert(GetTran("002202", "添加颜色成功!"))); divProductColor.Visible = false; } } } } if ((int)ViewState["ID"] == 2) { int updCount = 0; ///获取指定产品颜色的行数 int getCount = SetParametersBLL.GetProductColorCountByIDName(Convert.ToInt32(ViewState["ProductColorID"]), txtProductColorName.Text.Trim()); if (getCount > 0) { Page.ClientScript.RegisterStartupScript(GetType(), "", Transforms.ReturnAlert(GetTran("002201", "该颜色已经存在!"))); } else { BLL.CommonClass.ChangeLogs cl_h_info = new BLL.CommonClass.ChangeLogs("ProductColor", "ProductColorID"); cl_h_info.AddRecord(productColorModel.ProductColorID); using (SqlConnection conn = new SqlConnection(DBHelper.connString)) { conn.Open(); using (SqlTransaction tran = conn.BeginTransaction()) { try { ///修改指定产品颜色信息 value = SetParametersBLL.UpdProductColorByID(tran, productColorModel); language.UpdateNewTranslationRecord(tran, "ProductColor", "ProductColorName", Convert.ToInt32(ViewState["ProductColorID"]), productColorModel.ProductColorName); language.UpdateNewTranslationRecord(tran, "ProductColor", "ProductColorDescr", Convert.ToInt32(ViewState["ProductColorID"]), productColorModel.ProductColorDescr); tran.Commit(); } catch (Exception ex) { value = 0; tran.Rollback(); Page.ClientScript.RegisterStartupScript(GetType(), "", Transforms.ReturnAlert(GetTran("002208", "修改颜色失败,请联系管理员!"))); } if (value > 0) { cl_h_info.AddRecord(productColorModel.ProductColorID); cl_h_info.ModifiedIntoLogs(ChangeCategory.company28, Session["Company"].ToString(), ENUM_USERTYPE.objecttype9); Page.ClientScript.RegisterStartupScript(GetType(), "", Transforms.ReturnAlert(GetTran("002205", "修改颜色成功!"))); divProductColor.Visible = false; } } } } } DataBindProductColor(); } else { return; } }