示例#1
0
        protected void grvPartitionManager_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
        {
            string strCn = e.NewValues["ConnectString"] + "";
            string code = e.NewValues["Code"] + "";
            int    IDUser = 0, id_DV = 0;

            if (e.NewValues[4] != null)
            {
                IDUser = int.Parse(e.NewValues[4] + "");
            }
            if (e.NewValues[2] != null)
            {
                id_DV = int.Parse(e.NewValues[2] + "");
            }
            TestConnect(strCn, code);
            var sysPartitionService = new DM_MODULEService();
            SYS_ConfigConnectionServer configConnectionServer = new SYS_ConfigConnectionServer();
            var partition = new DM_MODULE
            {
                Name          = e.NewValues["Name"] + "",
                Code          = code,
                IDUSER        = IDUser,
                IDMA_DVIQLY   = id_DV,
                ConnectString = configConnectionServer.EncryptSYS_ConfigConnection(strCn)
            };

            sysPartitionService.InsertDM_MODULE(partition);
            _DataBind();
            e.Cancel = true;
            grvModunManager.CancelEdit();
            //WriteLog("Insert " + e.NewValues["Name"] + "", Action.Create);
        }
示例#2
0
        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.");
            }
        }
示例#3
0
        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);
        }
示例#4
0
        protected void grvPartitionManager_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e)
        {
            var sysModunService = new DM_MODULEService();
            var Modun           = new DM_MODULE {
                IDMODULE = (int)e.Keys["IDMODULE"]
            };

            sysModunService.DeleteDM_MODULE(Modun);
            _DataBind();
            e.Cancel = true;
            //WriteLog("Delete " + Modun.Name, Action.Delete);
        }
示例#5
0
        private void _DataBind()
        {
            List <DM_MODULE> lstModun = new List <DM_MODULE>();
            List <DM_MODULE> lst      = new List <DM_MODULE>();
            var sysModunService       = new DM_MODULEService();
            SYS_ConfigConnectionServer configConnectionServer = new SYS_ConfigConnectionServer();

            lstModun = sysModunService.SelectAllDM_MODULE();
            foreach (DM_MODULE sysModun in lstModun)
            {
                string temp = "";
                temp = configConnectionServer.DecryptSYS_ConfigConnection(sysModun.ConnectString);
                sysModun.ConnectString = temp;
                lst.Add(sysModun);
            }
            grvModunManager.DataSource = lst;
            grvModunManager.DataBind();
        }