protected void grvPartitionManager_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e) { string strCn = e.NewValues["ConnectString"] + ""; string code = e.NewValues["Code"] + ""; int IDUser = 0; if (e.NewValues[3] != null) { IDUser = int.Parse(e.NewValues[3] + ""); } TestConnect(strCn, code); var sysPartitionService = new SYS_ModunService(); SYS_ConfigConnectionServer configConnectionServer = new SYS_ConfigConnectionServer(); var partition = new SYS_Modun { Name = e.NewValues["Name"] + "", Code = code, idUser = IDUser, ConnectString = configConnectionServer.EncryptSYS_ConfigConnection(strCn) }; sysPartitionService.InsertSYS_Modun(partition); _DataBind(); e.Cancel = true; grvModunManager.CancelEdit(); //WriteLog("Insert " + e.NewValues["Name"] + "", Action.Create); }
protected void TestConnect(string strcn, string Code) { var sys_configconnection = new SYS_ConfigConnection(); var isys_configconnection = new SYS_ConfigConnectionServer(); sys_configconnection.connection = strcn; var sysModunService = new SYS_ModunService(); List <SYS_Modun> sysModun = sysModunService.SelectAllSYS_Modun(); for (int i = 0; i < sysModun.Count; i++) { if (Code.Trim() == sysModun[i].Code.Trim()) { throw new Exception(GetLocalResourceObject("strErrMesageCode").ToString()); } } try { if (isys_configconnection.TestConnectSYS_ConfigConnection(sys_configconnection, "KoMH")) { Session["ConnectString"] = sys_configconnection.connection; } else { throw new Exception(GetLocalResourceObject("strErrMesage").ToString()); } } catch (Exception) { throw new Exception(GetLocalResourceObject("strErrMesage").ToString()); } }
protected void grvPartitionManager_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e) { string strCn = e.NewValues["ConnectString"] + ""; string code = e.NewValues["Code"] + ""; SYS_Modun sysModun = (SYS_Modun)grvModunManager.GetRow(grvModunManager.EditingRowVisibleIndex); int IDUser = sysModun.idUser; if (e.NewValues["UserName"] != null) { IDUser = int.Parse(e.NewValues["UserName"] + ""); } TestConnect(strCn, code); SYS_ConfigConnectionServer configConnectionServer = new SYS_ConfigConnectionServer(); var sysPartitionService = new SYS_ModunService(); var partition = new SYS_Modun { ID = (int)e.Keys["ID"], Name = e.NewValues["Name"] + "", Code = code, idUser = IDUser, ConnectString = configConnectionServer.EncryptSYS_ConfigConnection(strCn) }; sysPartitionService.UpdateSYS_Modun(partition); _DataBind(); e.Cancel = true; grvModunManager.CancelEdit(); //WriteLog("Update " + e.NewValues["Name"] + "", Action.Update); }
protected void TestConnect(string strcn, string Code) { var sys_configconnection = new SYS_ConfigConnection(); var isys_configconnection = new SYS_ConfigConnectionServer(); sys_configconnection.connection = strcn; var sysModunService = new DM_MODULEService(); List <DM_MODULE> sysModun = sysModunService.SelectAllDM_MODULE(); for (int i = 0; i < sysModun.Count; i++) { if (Code.Trim() == sysModun[i].Code.Trim()) { throw new Exception("Mã không được trùng."); } } try { if (isys_configconnection.TestConnectSYS_ConfigConnection(sys_configconnection, "KoMH")) { Session["ConnectString"] = sys_configconnection.connection; } else { throw new Exception("Không kết nối được đến Server này."); } } catch (Exception) { throw new Exception("Không kết nối được đến Server này."); } }
protected void grvPartitionManager_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e) { string strCn = e.NewValues["ConnectString"] + ""; string code = e.NewValues["Code"] + ""; DM_MODULE sysModun = (DM_MODULE)grvModunManager.GetRow(grvModunManager.EditingRowVisibleIndex); int IDUser = sysModun.IDUSER; int idDV = sysModun.IDMA_DVIQLY; int testInt = 0; if (e.NewValues["USERNAME"] != null) { if (int.TryParse(e.NewValues["USERNAME"] + "", out testInt)) { IDUser = int.Parse(e.NewValues["USERNAME"] + ""); } else { IDUser = returnIDUser(e.NewValues["USERNAME"] + ""); } } if (e.NewValues["NAME_DVIQLY"] != null) { if (int.TryParse(e.NewValues["NAME_DVIQLY"] + "", out testInt)) { idDV = int.Parse(e.NewValues["NAME_DVIQLY"] + ""); } else { idDV = returnIDMaDV(e.NewValues["NAME_DVIQLY"] + ""); } } if (e.OldValues["Code"].ToString() != e.NewValues["Code"].ToString()) { TestConnect(strCn, code); } SYS_ConfigConnectionServer configConnectionServer = new SYS_ConfigConnectionServer(); var sysPartitionService = new DM_MODULEService(); var partition = new DM_MODULE { IDMODULE = (int)e.Keys["IDMODULE"], Name = e.NewValues["Name"] + "", Code = code, IDUSER = IDUser, IDMA_DVIQLY = idDV, ConnectString = configConnectionServer.EncryptSYS_ConfigConnection(strCn) }; sysPartitionService.UpdateDM_MODULE(partition); _DataBind(); e.Cancel = true; grvModunManager.CancelEdit(); //WriteLog("Update " + e.NewValues["Name"] + "", Action.Update); }
private void _DataBind() { List <SYS_Modun> lstModun = new List <SYS_Modun>(); List <SYS_Modun> lst = new List <SYS_Modun>(); var sysModunService = new SYS_ModunService(); SYS_ConfigConnectionServer configConnectionServer = new SYS_ConfigConnectionServer(); lstModun = sysModunService.SelectAllSYS_Modun(); foreach (SYS_Modun sysModun in lstModun) { string temp = ""; temp = configConnectionServer.DecryptSYS_ConfigConnection(sysModun.ConnectString); sysModun.ConnectString = temp; lst.Add(sysModun); } grvModunManager.DataSource = lst; grvModunManager.DataBind(); }