private void DataTree() { SYS_Dictionary dic = new SYS_Dictionary(); string strWhere = "1=1"; if (CookieManager.GetCookieValue("uid") != "0") { strWhere = "IsCanEdit='1'"; } DataSet ds = dic.GetDictionaryType(strWhere); if (ds != null) { //绑定树 foreach (DataRow row in ds.Tables[0].Rows) { TreeNode node = new TreeNode(); node.Text = row["businTypeName"].ToString(); node.Value = row["businTypeID"].ToString(); tvDictionaryType.Nodes.Add(node); } } else { //加载数据失败 } }
protected void initPage() { //初始化字典类型 ControlBindHelper.DropDownListBind(ddl_type, "SYS_BusinType", "businTypeName", "businTypeID", " 1=1 ", "请选择类型!", "0"); if (Request.QueryString["did"] == null) { if (Request.QueryString["typeid"] != "0") { ddl_type.SelectedValue = Request.QueryString["typeid"]; } //this.txt_privilege.Text = ""; this.txt_name.Text = ""; this.cb_status.Checked = false; } else { //加载修改页面信息 bll_dic = new SYS_Dictionary(); entity_dic = bll_dic.GetModel(Request.QueryString["did"], Request.QueryString["tid"]); if (entity_dic != null) { this.txt_name.Text = entity_dic.BusinName; //this.txt_privilege.Text = entity_dic.privilege.ToString(); this.ddl_type.SelectedValue = entity_dic.BusinTypeID; this.ddl_type.Enabled = false; this.cb_status.Checked = entity_dic.IsForbid == "1"?true :false; } else { MessageBox.Show(this.Page, "加载数据失败!"); } } //txt_name.Focus(); }
public BaseResponse <bool> SaveBatchDictionary(List <DictionaryModel> request) { BaseResponse <bool> response = new BaseResponse <bool>(); var dictionaryRepository = unitOfWork.GetRepository <SYS_Dictionary>(); var dictionaryItemRepository = unitOfWork.GetRepository <SYS_DictionaryItem>(); foreach (var item in request) { SYS_Dictionary dictionary = Mapper.DynamicMap <SYS_Dictionary>(item); dictionaryRepository.Insert(dictionary); unitOfWork.Save(); foreach (var sub in item.Items) { SYS_DictionaryItem dictionaryItem = Mapper.DynamicMap <SYS_DictionaryItem>(sub); dictionaryItem.DictionaryID = dictionary.DictionaryID; dictionaryItemRepository.Insert(dictionaryItem); } } unitOfWork.Save(); return(response); }
protected void btn_Save_Click(object sender, ImageClickEventArgs e) { entity_dic = new IndustryPlatform.Model.SYS_DictionaryEntity(); #region 初始化数据 entity_dic.BusinName = this.txt_name.Text.Trim(); entity_dic.BusinTypeID = this.ddl_type.SelectedValue; entity_dic.IsForbid = this.cb_status.Checked == true ? "1" : "0"; //entity_dic.privilege = 0; //if (this.txt_privilege.Text.Trim()!="") // entity_dic.privilege = Convert.ToDecimal(this.txt_privilege.Text.Trim()); #endregion bll_dic = new SYS_Dictionary(); bool isOk = false; if (Request.QueryString["did"] == null) //添加 { if (bll_dic.Exists(entity_dic.BusinTypeID, entity_dic.BusinName, "")) { MessageBox.Show(this.upDepartAdd, this, "您输入的名称在[" + this.ddl_type.SelectedItem.Text + "]类型中已经存在,请重新输入!"); return; } lock (this) { entity_dic.BusinID = DbHelperSQL.GetMaxID("businID", "SYS_Dictionary", " businTypeID=" + entity_dic.BusinTypeID).ToString(); // 获得最大ID isOk = bll_dic.Add(entity_dic); } } else //修改 { entity_dic.BusinID = Request.QueryString["did"]; if (bll_dic.Exists(entity_dic.BusinTypeID, entity_dic.BusinName, entity_dic.BusinID)) { MessageBox.Show(this.upDepartAdd, this, "您输入的名称在[" + this.ddl_type.SelectedItem.Text + "]类型中已经存在,请重新输入!"); return; } //entity_dic.businTypeID = Request.QueryString["tid"]; isOk = bll_dic.Update(entity_dic); } if (isOk) { #region 数据同步 if (ConfigurationManager.AppSettings["IsSync"] == "1") { try { ////添加成功,数据同步到各个磅房 IndustryPlatform.DBUtility.MsmqManage msm = MsmqManage.GetMsmq(); if (entity_dic.DisplayOrder == null) { entity_dic.DisplayOrder = 0; } if (Request.QueryString["did"] == null || Request.QueryString["did"] == "") {//添加 string strSQL = "INSERT INTO Sys_Dictionary ( " + "[BusinID] ," + "[BusinName] ," + "[BusinTypeID] ," + "[DisplayOrder] ," + "[IsForbid] ," + "[OtherInfo] ) VALUES ('" + entity_dic.BusinID + "','" + entity_dic.BusinName + "','" + entity_dic.BusinTypeID + "'," + entity_dic.DisplayOrder + ",'" + entity_dic.IsForbid + "','')"; strSQL = msm.AllStation + msm.Prefix + "Sys_Dictionary" + msm.Prefix + msm.AddFlg + msm.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + msm.Prefix + strSQL; msm.AddMsmq(strSQL); } else {//修改 string strSQL = "Delete From Sys_Dictionary Where BusinID='" + entity_dic.BusinID + "' And BusinTypeID='" + entity_dic.BusinTypeID + "';"; strSQL += "INSERT INTO Sys_Dictionary ( " + "[BusinID] ," + "[BusinName] ," + "[BusinTypeID] ," + "[DisplayOrder] ," + "[IsForbid] ," + "[OtherInfo] ) VALUES ('" + entity_dic.BusinID + "','" + entity_dic.BusinName + "','" + entity_dic.BusinTypeID + "'," + entity_dic.DisplayOrder + ",'" + entity_dic.IsForbid + "','');"; strSQL = msm.AllStation + msm.Prefix + "Sys_Dictionary" + msm.Prefix + msm.DelFlg + msm.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + msm.Prefix + strSQL; msm.AddMsmq(strSQL); } //List<string> iplist = ControlBindHelper.GetAllRoomIP(); //for (int i = 0; i < iplist.Count; i++) //{ // if (iplist[i] != "") // { // EndpointAddress ep = new EndpointAddress("net.msmq://" + iplist[i] + "/private/STOCMessagingQueue"); // NetMsmqBinding et = new NetMsmqBinding(); // et.ExactlyOnce = false; // et.Security.Mode = System.ServiceModel.NetMsmqSecurityMode.None; // IDataPublish proxy = ChannelFactory<IDataPublish>.CreateChannel(et, ep); // if (Request.QueryString["did"] == null) // proxy.IndustryPlatform_Dictionary_Add(entity_dic); // else // proxy.IndustryPlatform_Dictionary_Update(entity_dic); // } //} } catch { } } #endregion if (Request.QueryString["did"] == null) { MessageBox.Show(this.upDepartAdd, this, "保存成功!"); initPage(); } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "myscript", "top.currForm.close();", true); } } else { MessageBox.Show(this.upDepartAdd, this, "保存失败!"); } }