Пример #1
0
        protected void ctlTaxGrid_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "UserEdit")
            {
                int rowIndex = ((GridViewRow)((ImageButton)e.CommandSource).NamingContainer).RowIndex;
                long taxId = Convert.ToInt64(ctlTaxGrid.DataKeys[rowIndex].Value);
                ctlTaxForm.PageIndex = (ctlTaxGrid.PageIndex * ctlTaxGrid.PageSize) + rowIndex;
                ctlTaxForm.ChangeMode(FormViewMode.Edit);
                IList<DbTax> taxList = new List<DbTax>();
                DbTax tax = DbTaxService.FindByIdentity(taxId);
                taxList.Add(tax);

                ctlTaxForm.DataSource = taxList;
                ctlTaxForm.DataBind();
                ctlTaxGrid.DataCountAndBind();

                UpdatePanelTaxForm.Update();
                ctlTaxModalPopupExtender.Show();
            }
            else if (e.CommandName == "UserDelete")
            {
                try
                {
                    int rowIndex = ((GridViewRow)((ImageButton)e.CommandSource).NamingContainer).RowIndex;
                    long taxId = Convert.ToInt64(ctlTaxGrid.DataKeys[rowIndex].Value);
                    DbTax tax = DbTaxService.FindByIdentity(taxId);
                    DbTaxService.Delete(tax);
                }
                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);
                        ctlTaxGrid.DataCountAndBind();
                        ctlUpdatePanelGridview.Update();
                    }
                }
                ctlTaxGrid.DataCountAndBind();
                ctlUpdatePanelGridview.Update();
            }
            else if (e.CommandName == "Company")
            {
                int rowIndex = ((GridViewRow)((LinkButton)e.CommandSource).NamingContainer).RowIndex;
                long taxId = Convert.ToInt64(ctlTaxGrid.DataKeys[rowIndex].Value);

                ctlCompanyTaxInfo1.Initialize(taxId);
                ctlCompanyTaxInfo1.Show();
        }
        }
Пример #2
0
        protected void ctlTaxForm_ItemInserting(object sender, FormViewInsertEventArgs e)
        {
            DbTax dbTax = new DbTax();
            TextBox txtTaxCode = ctlTaxForm.FindControl("ctlTaxCode") as TextBox;
            TextBox txtTaxName = ctlTaxForm.FindControl("ctlTaxName") as TextBox;
            TextBox txtGL = ctlTaxForm.FindControl("ctlGL") as TextBox;
            TextBox txtRate = ctlTaxForm.FindControl("ctlRate") as TextBox;
            TextBox txtRateNonDeduct = ctlTaxForm.FindControl("ctlRateNonDeduct") as TextBox;
            CheckBox ctlActive = ctlTaxForm.FindControl("ctlActive") as CheckBox;
            CheckBox ctlApplyAllCompany = ctlTaxForm.FindControl("ctlApplyAllCompany") as CheckBox;

            dbTax.TaxCode = txtTaxCode.Text;
            dbTax.TaxName = txtTaxName.Text;
            dbTax.GL = txtGL.Text;
            if (!string.IsNullOrEmpty(txtRate.Text))
                dbTax.Rate = UIHelper.ParseDouble(txtRate.Text);
            else
                dbTax.Rate = -1;
            dbTax.RateNonDeduct = UIHelper.ParseDouble(txtRateNonDeduct.Text);
            dbTax.Active = ctlActive.Checked;
            dbTax.ApplyAllCompany = ctlApplyAllCompany.Checked;

            dbTax.UpdPgm = ProgramCode;
            dbTax.CreDate = DateTime.Now.Date;
            dbTax.UpdDate = DateTime.Now.Date;
            dbTax.CreBy = UserAccount.UserID;
            dbTax.UpdBy = UserAccount.UserID;
            
            try
            {
                DbTaxService.AddTax(dbTax);
                e.Cancel = true;
                ctlTaxGrid.DataCountAndBind();
                ctlTaxForm.ChangeMode(FormViewMode.ReadOnly);
                ClosePopUp();

            }
            catch (ServiceValidationException ex)
            {
                ValidationErrors.MergeErrors(ex.ValidationErrors);
            }
        }
Пример #3
0
        protected void ctlTaxForm_ItemUpdating(object sender, FormViewUpdateEventArgs e)
        {
            long taxId = UIHelper.ParseLong(ctlTaxForm.DataKey.Value.ToString());
            DbTax dbTax = DbTaxService.FindByIdentity(taxId);

            TextBox txtTaxCode = ctlTaxForm.FindControl("ctlEditTaxCode") as TextBox;
            TextBox txtTaxName = ctlTaxForm.FindControl("ctlEditTaxName") as TextBox;
            TextBox txtGL = ctlTaxForm.FindControl("ctlEditGL") as TextBox;
            TextBox txtRate = ctlTaxForm.FindControl("ctlEditRate") as TextBox;
            TextBox txtRateNonDeduct = ctlTaxForm.FindControl("ctlEditRateNonDeduct") as TextBox;
            CheckBox ctlActive = ctlTaxForm.FindControl("ctlActive") as CheckBox;
            CheckBox ctlApplyAllCompany = ctlTaxForm.FindControl("ctlApplyAllCompany") as CheckBox;

            dbTax.TaxCode = txtTaxCode.Text;
            dbTax.TaxName = txtTaxName.Text;
            dbTax.GL = txtGL.Text;
            dbTax.Rate = UIHelper.ParseDouble(txtRate.Text);
            dbTax.RateNonDeduct = UIHelper.ParseDouble(txtRateNonDeduct.Text);
            dbTax.Active = ctlActive.Checked;
            dbTax.ApplyAllCompany = ctlApplyAllCompany.Checked;

            dbTax.UpdPgm = ProgramCode;
            dbTax.UpdDate = DateTime.Now.Date;
            dbTax.UpdBy = UserAccount.UserID;

            try
            {
                DbTaxService.UpdateTax(dbTax);
                ctlTaxGrid.DataCountAndBind();
                ctlTaxForm.ChangeMode(FormViewMode.ReadOnly);
                ClosePopUp();
            }
            catch (ServiceValidationException ex)
            {
                ValidationErrors.MergeErrors(ex.ValidationErrors);
            }
        }