Пример #1
0
        protected void ctlAdd_Click(object sender, ImageClickEventArgs e)
        {
            try
            {
                DbAccountCompany accountCom = null;
                if (Mode.Equals(FlagEnum.EditFlag))
                {
                    accountCom = ScgDbQueryProvider.DbAccountCompanyQuery.FindByIdentity(ExpenseCompanyID);
                }

                if (accountCom != null)
                {
                    accountCom.UseParent     = ctlUseParent.Checked;
                    accountCom.TaxCode       = Convert.ToInt32(ctlTaxCode.SelectedValue);
                    accountCom.CostCenter    = Convert.ToInt32(ctlCostCenter.SelectedValue);
                    accountCom.InternalOrder = Convert.ToInt32(ctlInternalOrder.SelectedValue);
                    accountCom.SaleOrder     = Convert.ToInt32(ctlInternalOrder.SelectedValue);
                    //DbCompany com = ScgDbQueryProvider.DbCompanyQuery.FindByIdentity(UIHelper.ParseLong(ctlCompanyField.CompanyID));
                    //if (com != null)
                    //{

                    //    accountCom.CompanyID = new DbCompany(com.CompanyID);
                    //    accountCom.CompanyCode = com.CompanyCode;
                    //}

                    //DbAccount ac = ScgDbQueryProvider.DbAccountQuery.FindByIdentity(AccountID);
                    //if (ac != null)
                    //{
                    //    accountCom.AccountID = new DbAccount(ac.AccountID);
                    //}
                    accountCom.Active  = true;
                    accountCom.CreBy   = UserAccount.UserID;
                    accountCom.CreDate = DateTime.Now;
                    accountCom.UpdBy   = UserAccount.UserID;
                    accountCom.UpdDate = DateTime.Now;
                    accountCom.UpdPgm  = UserAccount.CurrentProgramCode;

                    if (Mode.Equals(FlagEnum.EditFlag))
                    {
                        DbAccountCompanyService.Update(accountCom);
                    }
                }

                if (Notify_Ok != null)
                {
                    Notify_Ok(sender, e);
                }

                HidePopUp();
            }
            catch (ServiceValidationException ex)
            {
                this.ValidationErrors.MergeErrors(ex.ValidationErrors);
            }
        }
        protected void EditorLookup_OnObjectLookUpReturn(object sender, ObjectLookUpReturnArgs e)
        {
            ShowAdd.Text    = null;
            ShowAdd.Visible = false;
            IList <DbCompany> account = (List <DbCompany>)e.ObjectReturn;

            IList <DbAccountCompany> list = new List <DbAccountCompany>();
            ArrayList groupComList        = new ArrayList();

            foreach (GridViewRow row in ctlCompanyInfoGrid.Rows)
            {
                Label ctlCom = (Label)ctlCompanyInfoGrid.Rows[row.RowIndex].FindControl("ctlCompanyCode");

                groupComList.Add(ctlCom.Text);
            }
            foreach (DbCompany ac in account)
            {
                if (!groupComList.Contains(ac.CompanyCode))
                {
                    DbAccountCompany accountCompany = new DbAccountCompany();
                    accountCompany.AccountID = ScgDbQueryProvider.DbAccountQuery.FindByIdentity(AccountID);
                    accountCompany.UseParent = true;
                    accountCompany.Active    = true;
                    accountCompany.CompanyID = ac;
                    accountCompany.CreBy     = UserAccount.UserID;
                    accountCompany.CreDate   = DateTime.Now;
                    accountCompany.UpdBy     = UserAccount.UserID;
                    accountCompany.UpdDate   = DateTime.Now;
                    accountCompany.UpdPgm    = UserAccount.CurrentProgramCode;

                    list.Add(accountCompany);
                }

                else
                {
                    ShowAdd.Text   += "COMPANY CODE " + ac.CompanyCode + " ALREADY ADDED <br>";
                    ShowAdd.Visible = true;
                }
            }

            DbAccountCompanyService.AddAccountCompanyList(list);
            ctlCompanyInfoGrid.DataCountAndBind();
            ctlCompanyInfoUpdatePanel.Update();
        }
 protected void DeleteCompanyInfo_Click(object sender, ImageClickEventArgs e)
 {
     foreach (GridViewRow row in ctlCompanyInfoGrid.Rows)
     {
         if ((row.RowType == DataControlRowType.DataRow) && (((CheckBox)row.FindControl("ctlSelect")).Checked))
         {
             try
             {
                 long             id = UIHelper.ParseLong(ctlCompanyInfoGrid.DataKeys[row.RowIndex]["ID"].ToString());
                 DbAccountCompany ac = ScgDbQueryProvider.DbAccountCompanyQuery.FindByIdentity(id);
                 DbAccountCompanyService.Delete(ac);
             }
             catch (Exception ex)
             {
                 string exMessage = ex.Message;
                 Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors();
                 errors.AddError("DbAccountCompany.Error", new Spring.Validation.ErrorMessage("CannotDelete"));
                 ValidationErrors.MergeErrors(errors);
             }
         }
     }
     ctlCompanyInfoGrid.DataCountAndBind();
     ctlCompanyInfoUpdatePanel.Update();
 }