Esempio n. 1
0
        public static void UpdateNewOrderDetails2(System.Windows.Controls.DataGrid grid, System.Data.Linq.EntitySet <OrderDetail> targetList)
        {
            int selIndex  = grid.SelectedIndex;
            int diffIndex = grid.Items.Count - selIndex;

            if (diffIndex == 1)
            {
                //add item
                OrderDetail newOrderDetail = GetNewOrderDetail(true);

                //2011-4-2 새로추가
                if (newOrderDetail != null)
                {
                    targetList.Add(newOrderDetail);
                    DataManager.Submit();
                }
                grid.SelectedIndex = -1;
            }
            else if (selIndex > -1)
            {
                OrderDetail newOrderDetail = GetNewOrderDetail(false);
                if (newOrderDetail != null)
                {
                    targetList[selIndex] = newOrderDetail;
                    DataManager.Submit();
                }
                else
                {
                    targetList.RemoveAt(selIndex);
                    DataManager.Submit();
                }
            }
        }
Esempio n. 2
0
        private void btnAddTransaction_Click(object sender, EventArgs e)
        {
            try
            {
                if (ConvertToInt(comboEvent.SelectedValue) == 0)
                {
                    comboEvent.Focus();
                }
                else
                {
                    gvTransaction.DataSource             = trnbookeventBindingSource;
                    trnbookeventBindingSource.DataSource = new System.Data.Linq.EntitySet <trn_book_event>();
                    var dateNow = DateTime.Now;
                    _ListBookEvent.Add(new trn_book_event
                    {
                        mbe_id          = ConvertToInt(comboEvent.SelectedValue),
                        tbe_remark      = txtTransaction.Text,
                        tbe_date        = dateTransaction.Value.Date.Add(ConvertToTime(txtTime.Text)),
                        tbe_active      = true,
                        tbe_create_by   = Program.CurrentUser.mut_username,
                        tbe_create_date = dateNow,
                        tbe_update_by   = Program.CurrentUser.mut_username,
                        tbe_update_date = dateNow
                    });
                    comboEvent.SelectedValue = 0;
                    txtTransaction.Text      = "";

                    gvTransaction.DataSource             = trnbookeventBindingSource;
                    trnbookeventBindingSource.DataSource = _ListBookEvent;
                    panel1.Enabled = true;
                    trnbookeventBindingSource.Sort = "tbe_create_date DESC";
                    //setRowNo();
                }
            }
            catch
            {
            }
        }
        public ActionResult Edit(int id, FormCollection collection)
        {
            //Get Item From Database
            ApprovalGroup group = new ApprovalGroup();

            group = approvalGroupRepository.GetGroup(id);

            //Check Exists
            if (group == null)
            {
                ViewData["ActionMethod"] = "EditPost";
                return(View("RecordDoesNotExistError"));
            }

            //Check Access
            RolesRepository rolesRepository = new RolesRepository();

            if (!rolesRepository.HasWriteAccessToApprovalGroup(group.ApprovalGroupId))
            {
                return(View("Error"));
            }

            //Update Model From Form + Validate against DB
            try
            {
                UpdateModel(group);
            }
            catch
            {
                string n = "";
                foreach (ModelState modelState in ViewData.ModelState.Values)
                {
                    foreach (ModelError error in modelState.Errors)
                    {
                        n += error.ErrorMessage;
                    }
                }
                ViewData["Message"] = "ValidationError : " + n;
                return(View("Error"));
            }

            if (group.HierarchyType != "Multiple")
            {
                //ClientSubUnitTravelerType has extra field
                string hierarchyCode = group.HierarchyCode;
                if (group.HierarchyType == "ClientSubUnitTravelerType")
                {
                    group.ClientSubUnitGuid = hierarchyCode;  //ClientSubUnitTravelerType has 2 primarykeys
                }

                //Check Access Rights to Hierarchy
                HierarchyRepository hierarchyRepository = new HierarchyRepository();
                if (!hierarchyRepository.AdminHasDomainHierarchyWriteAccess(group.HierarchyType, hierarchyCode, group.SourceSystemCode, groupName))
                {
                    ViewData["Message"] = "You cannot add to this hierarchy item";
                    return(View("Error"));
                }
            }

            //Create Approval Group Approval Type Items from Post values
            System.Data.Linq.EntitySet <ApprovalGroupApprovalTypeItem> approvalGroupApprovalTypeItems = new System.Data.Linq.EntitySet <ApprovalGroupApprovalTypeItem>();

            foreach (string key in collection)
            {
                if (key.StartsWith("ApprovalGroupApprovalTypeItem") && !string.IsNullOrEmpty(collection[key]))
                {
                    string[] values = collection[key].Split(',');

                    if (values[0] != null && values[1] != null && !string.IsNullOrEmpty(values[0]) && !string.IsNullOrEmpty(values[1]))
                    {
                        ApprovalGroupApprovalTypeItem approvalGroupApprovalTypeItem = new ApprovalGroupApprovalTypeItem()
                        {
                            ApprovalGroupApprovalTypeId        = int.Parse(values[0]),
                            ApprovalGroupApprovalTypeItemValue = values[1]
                        };
                        approvalGroupApprovalTypeItems.Add(approvalGroupApprovalTypeItem);
                    }
                }
            }

            //Remove Approval Group Approval Type Items if not set, otherwise add new ones in
            group.ApprovalGroupApprovalTypeItems = (approvalGroupApprovalTypeItems != null && approvalGroupApprovalTypeItems.Count > 0) ? approvalGroupApprovalTypeItems : null;

            //Database Update
            try
            {
                approvalGroupRepository.Edit(group);
            }
            catch (SqlException ex)
            {
                //Versioning Error
                if (ex.Message == "SQLVersioningError")
                {
                    ViewData["ReturnURL"] = "/ApprovalGroup.mvc/Edit/" + group.ApprovalGroupId.ToString();
                    return(View("VersionError"));
                }
                LogRepository logRepository = new LogRepository();
                logRepository.LogError(ex.Message);

                ViewData["Message"] = "There was a problem with your request, please see the log file or contact an administrator for details";
                return(View("Error"));
            }
            return(RedirectToAction("ListUnDeleted"));
        }
        public ActionResult Create(ApprovalGroup group, FormCollection collection)
        {
            //Check Access Rights to Domain
            if (!hierarchyRepository.AdminHasDomainWriteAccess(groupName))
            {
                ViewData["Message"] = "You do not have access to this item";
                return(View("Error"));
            }
            //Check Access Rights to Domain Hierarchy
            if (!hierarchyRepository.AdminHasDomainHierarchyWriteAccess(group.HierarchyType, group.HierarchyCode, group.SourceSystemCode, groupName))
            {
                ViewData["Message"] = "You cannot add to this hierarchy item";
                return(View("Error"));
            }

            //Update Model From Form + Validate against DB
            try
            {
                UpdateModel(group);
            }
            catch
            {
                string n = "";
                foreach (ModelState modelState in ViewData.ModelState.Values)
                {
                    foreach (ModelError error in modelState.Errors)
                    {
                        n += error.ErrorMessage;
                    }
                }
                ViewData["Message"] = "ValidationError : " + n;
                return(View("Error"));
            }

            //ClientSubUnitTravelerType has extra field
            string hierarchyCode = group.HierarchyCode;

            if (group.HierarchyType == "ClientSubUnitTravelerType")
            {
                group.ClientSubUnitGuid = hierarchyCode;  //ClientSubUnitTravelerType has 2 primarykeys
            }

            //Create Approval Group Approval Type Items from Post values
            System.Data.Linq.EntitySet <ApprovalGroupApprovalTypeItem> approvalGroupApprovalTypeItems = new System.Data.Linq.EntitySet <ApprovalGroupApprovalTypeItem>();

            foreach (string key in collection)
            {
                if (key.StartsWith("ApprovalGroupApprovalTypeItem") && !string.IsNullOrEmpty(collection[key]))
                {
                    string[] values = collection[key].Split(',');

                    if (values[0] != null && values[1] != null && !string.IsNullOrEmpty(values[0]) && !string.IsNullOrEmpty(values[1]))
                    {
                        ApprovalGroupApprovalTypeItem approvalGroupApprovalTypeItem = new ApprovalGroupApprovalTypeItem()
                        {
                            ApprovalGroupApprovalTypeId        = int.Parse(values[0]),
                            ApprovalGroupApprovalTypeItemValue = values[1]
                        };
                        approvalGroupApprovalTypeItems.Add(approvalGroupApprovalTypeItem);
                    }
                }
            }

            //Add Approval Group Approval Type Items
            group.ApprovalGroupApprovalTypeItems = approvalGroupApprovalTypeItems;

            //Database Update
            try
            {
                approvalGroupRepository.Add(group);
            }
            catch (SqlException ex)
            {
                //Non-Unique Name
                if (ex.Message == "NonUniqueName")
                {
                    return(View("NonUniqueNameError"));
                }
                LogRepository logRepository = new LogRepository();
                logRepository.LogError(ex.Message);

                ViewData["Message"] = "There was a problem with your request, please see the log file or contact an administrator for details";
                return(View("Error"));
            }
            ViewData["NewSortOrder"] = 0;
            return(RedirectToAction("ListUnDeleted"));
        }
Esempio n. 5
0
        public ActionResult Edit(PolicySupplierDealCode policySupplierDealCode, FormCollection formCollection)
        {
            PolicyGroup policyGroup = new PolicyGroup();

            policyGroup = policyGroupRepository.GetGroup(policySupplierDealCode.PolicyGroupId);

            //Check Exists
            if (policyGroup == null)
            {
                ViewData["ActionMethod"] = "EditPost";
                return(View("RecordDoesNotExistError"));
            }

            //Check Access Rights
            RolesRepository rolesRepository = new RolesRepository();

            if (!rolesRepository.HasWriteAccessToPolicyGroup(policySupplierDealCode.PolicyGroupId))
            {
                ViewData["Message"] = "You do not have access to this item";
                return(View("Error"));
            }

            //Create PolicySupplierDealCodeOSIs from Post values
            System.Data.Linq.EntitySet <PolicySupplierDealCodeOSI> PolicySupplierDealCodeOSIs = new System.Data.Linq.EntitySet <PolicySupplierDealCodeOSI>();

            foreach (string key in formCollection)
            {
                if (key.StartsWith("PolicySupplierDealCodeOSI") && !string.IsNullOrEmpty(formCollection[key]))
                {
                    PolicySupplierDealCodeOSI policySupplierDealCodeOSI = new PolicySupplierDealCodeOSI()
                    {
                        PolicySupplierDealCodeOSIDescription    = formCollection[key],
                        PolicySupplierDealCodeOSISequenceNumber = int.Parse(key.Replace("PolicySupplierDealCodeOSI_", ""))
                    };

                    PolicySupplierDealCodeOSIs.Add(policySupplierDealCodeOSI);
                }
            }

            if (PolicySupplierDealCodeOSIs != null && PolicySupplierDealCodeOSIs.Count > 0)
            {
                policySupplierDealCode.PolicySupplierDealCodeOSIs = PolicySupplierDealCodeOSIs;
            }

            //Update PolicySupplierDealCode Model From Form
            try
            {
                UpdateModel(policySupplierDealCode, "PolicySupplierDealCode");
            }
            catch
            {
                string n = "";
                foreach (ModelState modelState in ViewData.ModelState.Values)
                {
                    foreach (ModelError error in modelState.Errors)
                    {
                        n += error.ErrorMessage;
                    }
                }
                ViewData["Message"] = "ValidationError : " + n;
                return(View("Error"));
            }

            //Database Update
            try
            {
                policySupplierDealCodeRepository.Update(policySupplierDealCode);
            }
            catch (SqlException ex)
            {
                //Versioning Error
                if (ex.Message == "SQLVersioningError")
                {
                    ViewData["ReturnURL"] = "/PolicySupplierDealCode.mvc/Edit/" + policySupplierDealCode.PolicySupplierDealCodeId;
                    return(View("VersionError"));
                }

                //Generic Error
                ViewData["Message"] = "There was a problem with your request, please see the log file or contact an administrator for details";
                return(View("Error"));
            }

            //Return to Form
            return(RedirectToAction("List", new { id = policySupplierDealCode.PolicyGroupId }));
        }
        public ActionResult Edit(GDSEndWarningConfigurationVM gdsEndWarningConfigurationVM, FormCollection formCollection)
        {
            //Get Item
            GDSEndWarningConfiguration gdsEndWarningConfiguration = new GDSEndWarningConfiguration();

            gdsEndWarningConfiguration = gdsEndWarningConfigurationRepository.GetGroup(gdsEndWarningConfigurationVM.GDSEndWarningConfiguration.GDSEndWarningConfigurationId);

            //Check Exists
            if (gdsEndWarningConfiguration == null)
            {
                ViewData["ActionMethod"] = "EditPost";
                return(View("RecordDoesNotExistError"));
            }

            //Check Access Rights
            if (!rolesRepository.HasWriteAccessToGDSEndWarningConfiguration())
            {
                ViewData["Message"] = "You do not have access to this item";
                return(View("Error"));
            }

            //Create Automated Commands from Post values
            System.Data.Linq.EntitySet <AutomatedCommand> AutomatedCommands = new System.Data.Linq.EntitySet <AutomatedCommand>();

            foreach (string key in formCollection)
            {
                if (key.StartsWith("AutomatedCommand") && !string.IsNullOrEmpty(formCollection[key]))
                {
                    AutomatedCommand automatedCommand = new AutomatedCommand()
                    {
                        CommandText = formCollection[key],
                        CommandExecutionSequenceNumber = int.Parse(key.Replace("AutomatedCommand_", ""))
                    };

                    AutomatedCommands.Add(automatedCommand);
                }
            }

            //Remove Automated Commands if not set, otherwise add new ones in
            gdsEndWarningConfiguration.AutomatedCommands = (AutomatedCommands != null && AutomatedCommands.Count > 0) ? AutomatedCommands : null;

            //Update Model From Form + Validate against DB
            try
            {
                UpdateModel <GDSEndWarningConfiguration>(gdsEndWarningConfiguration, "GDSEndWarningConfiguration");
            }
            catch
            {
                string n = "";
                foreach (ModelState modelState in ViewData.ModelState.Values)
                {
                    foreach (ModelError error in modelState.Errors)
                    {
                        n += error.ErrorMessage;
                    }
                }
                ViewData["Message"] = "ValidationError : " + n;
                return(View("Error"));
            }

            //Database Update
            try
            {
                gdsEndWarningConfigurationRepository.Edit(gdsEndWarningConfiguration);
            }
            catch (SqlException ex)
            {
                //Non-Unique Name
                if (ex.Message == "NonUniqueName")
                {
                    return(View("NonUniqueNameError"));
                }
                //Versioning Error
                if (ex.Message == "SQLVersioningError")
                {
                    ViewData["ReturnURL"] = "/GDSEndWarningConfiguration.mvc/Edit/" + gdsEndWarningConfiguration.GDSEndWarningConfigurationId;
                    return(View("VersionError"));
                }
                LogRepository logRepository = new LogRepository();
                logRepository.LogError(ex.Message);

                ViewData["Message"] = "There was a problem with your request, please see the log file or contact an administrator for details";
                return(View("Error"));
            }

            return(RedirectToAction("List"));
        }
        public ActionResult Create(GDSEndWarningConfigurationVM GDSEndWarningConfigurationVM, FormCollection formCollection)
        {
            //Check Access Rights to Domain
            if (!hierarchyRepository.AdminHasDomainWriteAccess(groupName))
            {
                ViewData["Message"] = "You do not have access to this item";
                return(View("Error"));
            }

            //We need to extract group from groupVM
            GDSEndWarningConfiguration gdsEndWarningConfiguration = new GDSEndWarningConfiguration();

            gdsEndWarningConfiguration = GDSEndWarningConfigurationVM.GDSEndWarningConfiguration;
            if (gdsEndWarningConfiguration == null)
            {
                ViewData["Message"] = "ValidationError : missing item";;
                return(View("Error"));
            }

            //Create Automated Commands from Post values
            System.Data.Linq.EntitySet <AutomatedCommand> AutomatedCommands = new System.Data.Linq.EntitySet <AutomatedCommand>();

            foreach (string key in formCollection)
            {
                if (key.StartsWith("AutomatedCommand") && !string.IsNullOrEmpty(formCollection[key]))
                {
                    AutomatedCommand automatedCommand = new AutomatedCommand()
                    {
                        CommandText = formCollection[key],
                        CommandExecutionSequenceNumber = int.Parse(key.Replace("AutomatedCommand_", ""))
                    };

                    AutomatedCommands.Add(automatedCommand);
                }
            }

            if (AutomatedCommands != null && AutomatedCommands.Count > 0)
            {
                gdsEndWarningConfiguration.AutomatedCommands = AutomatedCommands;
            }

            //Update Model From Form + Validate against DB
            try
            {
                UpdateModel <GDSEndWarningConfiguration>(gdsEndWarningConfiguration, "GDSEndWarningConfiguration");
            }
            catch
            {
                string n = "";
                foreach (ModelState modelState in ViewData.ModelState.Values)
                {
                    foreach (ModelError error in modelState.Errors)
                    {
                        n += error.ErrorMessage;
                    }
                }
                ViewData["Message"] = "ValidationError : " + n;
                return(View("Error"));
            }

            //Database Update
            try
            {
                gdsEndWarningConfigurationRepository.Add(gdsEndWarningConfiguration);
            }
            catch (SqlException ex)
            {
                //Non-Unique Name
                if (ex.Message == "NonUniqueName")
                {
                    return(View("NonUniqueNameError"));
                }

                LogRepository logRepository = new LogRepository();
                logRepository.LogError(ex.Message);

                ViewData["Message"] = "There was a problem with your request, please see the log file or contact an administrator for details";
                return(View("Error"));
            }

            ViewData["NewSortOrder"] = 0;
            return(RedirectToAction("List"));
        }