Exemple #1
0
        protected void ctlCurrency_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int rowIndex;

            if (e.CommandName.Equals("IOEdit"))
            {
                rowIndex        = ((GridViewRow)((ImageButton)e.CommandSource).NamingContainer).RowIndex;
                InternalOrderId = UIHelper.ParseLong(ctlIOGrid.DataKeys[rowIndex].Values["IOID"].ToString());


                ctlIOEditor.Initialize(FlagEnum.EditFlag, InternalOrderId);
                ctlIOEditor.ShowPopUp();
            }
            if (e.CommandName.Equals("IODelete"))
            {
                try
                {
                    rowIndex        = ((GridViewRow)((ImageButton)e.CommandSource).NamingContainer).RowIndex;
                    InternalOrderId = UIHelper.ParseLong(ctlIOGrid.DataKeys[rowIndex].Value.ToString());
                    DbInternalOrder io = ScgDbQueryProvider.DbIOQuery.FindByIdentity(InternalOrderId);
                    DbIOService.DeleteIO(io);
                }
                catch (Exception ex)
                {
                    if (((System.Data.SqlClient.SqlException)(ex.GetBaseException())).Number == 547)
                    {
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "AlertInUseData",
                                                                "alert('This data is now in use.');", true);
                        ctlIOGrid.DataCountAndBind();
                    }
                }

                ctlIOGrid.DataCountAndBind();
                ctlIOUpdatePanel.Update();
            }
        }
Exemple #2
0
        //protected void ctlCostCenterField_OnObjectLookUpReturn(object sender, ObjectLookUpReturnArgs e)
        //{
        //    DbCostCenter costCenter = (DbCostCenter)e.ObjectReturn;
        //    if (costCenter != null)
        //    {
        //        DbCostCenter dbCost = ScgDbQueryProvider.DbCostCenterQuery.FindProxyByIdentity(costCenter.CostCenterID);
        //        if (dbCost != null)
        //        {
        //            ctlCompanyCode.Text = dbCost.CompanyID.CompanyCode.ToString();
        //            ctlCompanyName.Text = dbCost.CompanyID.CompanyName;
        //        }
        //    }
        //    ctlIOUpdatePanel.Update();
        //}

        private void CheckDataValueUpdate(DbInternalOrder io)
        {
            Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors();
            if (string.IsNullOrEmpty(io.IONumber))
            {
                errors.AddError("InternalOrder.Error", new Spring.Validation.ErrorMessage("RequiredIONumber"));
            }
            if (string.IsNullOrEmpty(io.IOType))
            {
                errors.AddError("InternalOrder.Error", new Spring.Validation.ErrorMessage("RequiredIOType"));
            }
            if (string.IsNullOrEmpty(io.IOText))
            {
                errors.AddError("InternalOrder.Error", new Spring.Validation.ErrorMessage("RequiredIOText"));
            }
            if (io.CompanyID == null || io.CompanyID <= 0)
            {
                errors.AddError("InternalOrder.Error", new Spring.Validation.ErrorMessage("RequiredCompany"));
            }
            if (!(io.ExpireDate == null || io.EffectiveDate == null))
            {
                if (io.ExpireDate < io.EffectiveDate)
                {
                    errors.AddError("InternalOrder.Error", new Spring.Validation.ErrorMessage("ExpireDateMustBeMoreThanEffectiveDate"));
                }
            }
            if (DbIOService.IsExistIO(io) && Mode.Equals(FlagEnum.NewFlag))
            {
                errors.AddError("InternalOrder.Error", new Spring.Validation.ErrorMessage("Duplicate IO Code"));
            }

            if (!errors.IsEmpty)
            {
                throw new ServiceValidationException(errors);
            }
        }
Exemple #3
0
        protected void ctlInsert_Click1(object sender, ImageClickEventArgs e)
        {
            DbInternalOrder io;

            try
            {
                if (Mode.Equals(FlagEnum.EditFlag))
                {
                    io = ScgDbQueryProvider.DbIOQuery.FindByIdentity(IOID);
                }
                else
                {
                    io          = new DbInternalOrder();
                    io.IONumber = ctlIONumber.Text;
                }


                io.IOType       = ctlIOType.Text;
                io.IOText       = ctlIOText.Text;
                io.Active       = ctlIOActive.Checked;
                io.BusinessArea = ctlBusinessArea.Text;
                io.ProfitCenter = ctlProfitCenter.Text;

                DbCostCenter cost = ScgDbQueryProvider.DbCostCenterQuery.FindByIdentity(UIHelper.ParseLong(ctlCostCenterField.CostCenterId));
                if (cost != null)
                {
                    io.CostCenterID   = cost.CostCenterID;
                    io.CostCenterCode = cost.CostCenterCode;
                }

                DbCompany com = ScgDbQueryProvider.DbCompanyQuery.FindByIdentity(UIHelper.ParseLong(ctlCompanyField.CompanyID));
                if (com != null)
                {
                    io.CompanyID   = com.CompanyID;
                    io.CompanyCode = com.CompanyCode;
                }

                io.CreBy   = UserAccount.UserID;
                io.CreDate = DateTime.Now;
                io.UpdBy   = UserAccount.UserID;
                io.UpdDate = DateTime.Now;
                io.UpdPgm  = UserAccount.CurrentLanguageCode;

                if (!string.IsNullOrEmpty(ctlCalEffectiveDate.DateValue))
                {
                    try
                    {
                        io.EffectiveDate = UIHelper.ParseDate(ctlCalEffectiveDate.DateValue).Value;
                    }
                    catch {}
                }
                else
                {
                    io.EffectiveDate = null;
                }

                if (!string.IsNullOrEmpty(ctlCalLastDisplayDate.DateValue))
                {
                    try
                    {
                        io.ExpireDate = UIHelper.ParseDate(ctlCalLastDisplayDate.DateValue).Value;
                    }
                    catch { }
                }
                else
                {
                    io.ExpireDate = null;
                }

                CheckDataValueUpdate(io);
                if (Mode.Equals(FlagEnum.EditFlag))
                {
                    DbIOService.UpdateIO(io);
                }
                else
                {
                    DbIOService.AddIO(io);
                }
                Notify_Ok(sender, e);
            }
            catch (ServiceValidationException ex)
            {
                this.ValidationErrors.MergeErrors(ex.ValidationErrors);
            }

            catch (NullReferenceException)
            {
                //Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors();
                //errors.AddError("InternalOrder.Error", new ErrorMessage("CostCenter and Company Require."));
                //ValidationErrors.MergeErrors(errors);
                //return;
            }
        }