Esempio n. 1
0
 protected void GrdReport_ItemCommand(object source, RepeaterCommandEventArgs e)
 {
     try
     {
         switch (e.CommandName)
         {
         case ("Select"):
         {
             if (Convert.ToInt32(e.CommandArgument) != 0)
             {
                 ViewState["EditID"] = Convert.ToInt32(e.CommandArgument);
                 Ds = Obj_TaxMaster.GetTaxMasterForEdit(Convert.ToInt32(e.CommandArgument), out StrError);
                 if (Ds.Tables.Count > 0 && Ds.Tables[0].Rows.Count > 0)
                 {
                     TxtTaxName.Text = Ds.Tables[0].Rows[0]["TaxName"].ToString();
                     //TxtTaxPer.Text = Ds.Tables[0].Rows[0]["TaxPer"].ToString();
                     //TXTEFFECTIVEDATE.Text =!string.IsNullOrEmpty(Ds.Tables[0].Rows[0]["EffectiveFrom"].ToString())?Ds.Tables[0].Rows[0]["EffectiveFrom"].ToString():DateTime.Now.ToString("dd-MMM-yyyy");
                     ////TxtTaxName.Enabled = false;
                     //RdoTaxType.SelectedValue = !string.IsNullOrEmpty(Ds.Tables[0].Rows[0]["TaxTypeID"].ToString()) ? Convert.ToString((Ds.Tables[0].Rows[0]["TaxTypeID"].ToString())) : "1";
                 }
                 else
                 {
                     MakeEmptyForm();
                 }
                 if (Ds.Tables.Count > 0 && Ds.Tables[1].Rows.Count > 0)
                 {
                     GridDetails.DataSource = Ds.Tables[1];
                     GridDetails.DataBind();
                     ViewState["CurrentTable"] = Ds.Tables[1];
                 }
                 else
                 {
                     GridDetails.DataSource = null;
                     GridDetails.DataBind();
                     ViewState["CurrentTable"] = null;
                 }
                 Ds            = null;
                 Obj_TaxMaster = null;
                 if (!FlagEdit)
                 {
                     BtnUpdate.Visible = true;
                 }
                 BtnSave.Visible = false;
                 if (!FlagDel)
                 {
                     BtnDelete.Visible = true;
                 }
                 TxtTaxName.Focus();
             }
             break;
         }
         }
     }
     catch (Exception ex) { throw new Exception(ex.Message); }
 }
Esempio n. 2
0
    protected void BtnSave_Click(object sender, EventArgs e)
    {
        int InsertRow = 0, InserRowDtls = 0;

        try
        {
            Ds = Obj_TaxMaster.ChkDuplicate(TxtTaxName.Text.Trim(), out StrError);
            if (Ds.Tables[0].Rows.Count > 0)
            {
                obj_Comman.ShowPopUpMsg("Please Enter Another Tax Name..", this.Page);
                TxtTaxName.Focus();
            }
            else
            {
                Entity_TaxMaster.TaxName = TxtTaxName.Text.Trim();
                //Entity_TaxMaster.TaxPer = Convert.ToDecimal(TxtTaxPer.Text.Trim());
                //Entity_TaxMaster.EffectiveFrom = Convert.ToDateTime(TXTEFFECTIVEDATE.Text.Trim());
                Entity_TaxMaster.UserId    = Convert.ToInt32(Session["UserId"]);
                Entity_TaxMaster.LoginDate = DateTime.Now;
                ////Entity_TaxMaster.TaxTypeID = Convert.ToInt32(RdoTaxType.SelectedValue.ToString());
                InsertRow = Obj_TaxMaster.InsertRecord(ref Entity_TaxMaster, out StrError);

                for (int i = 0; i < GridDetails.Rows.Count; i++)
                {
                    Entity_TaxMaster.TaxId = InsertRow;
                    if ((GridDetails.Rows[i].Cells[2]).Text != "&nbsp;")
                    {
                        Entity_TaxMaster.ApplicableDate = DateTime.Parse((GridDetails.Rows[i].Cells[2]).Text);
                    }
                    else
                    {
                        Entity_TaxMaster.ApplicableDate = DateTime.Parse(DateTime.Now.ToString("dd/MMM/yyyy"));
                    }
                    Entity_TaxMaster.GST = Convert.ToDecimal(GridDetails.Rows[i].Cells[1].Text.ToString());

                    InserRowDtls = Obj_TaxMaster.InsertTaxtls(ref Entity_TaxMaster, out StrError);
                }
                if (InsertRow != 0)
                {
                    obj_Comman.ShowPopUpMsg("Record Saved Successfully", this.Page);
                    MakeEmptyForm();
                    Entity_TaxMaster = null;
                    Obj_TaxMaster    = null;
                }
            }
        }
        catch (Exception ex) { throw new Exception(ex.Message); }
    }
Esempio n. 3
0
    //private void SetInitialRow()
    //{
    //    DataTable dt = new DataTable();
    //    DataRow dr;

    //    dt.Columns.Add("#", typeof(Int32));
    //    dt.Columns.Add("From", typeof(string));
    //    dt.Columns.Add("To", typeof(string));
    //    dt.Columns.Add("Taxper", typeof(string));

    //    dr = dt.NewRow();

    //    dr["#"] = 0;
    //    dr["From"] = "";
    //    dr["To"] = "";
    //    dr["Taxper"] = "";

    //    dt.Rows.Add(dr);

    //    ViewState["CurrentTable"] = dt;
    //    Grd_Tax.DataSource = dt;
    //    Grd_Tax.DataBind();
    //}

    private void MakeEmptyForm()
    {
        ViewState["EditID"] = null;
        TxtTaxName.Focus();
        if (!FlagAdd)
        {
            BtnSave.Visible = true;
        }
        BtnDelete.Visible        = false;
        BtnUpdate.Visible        = false;
        RdoTaxType.SelectedValue = "1";
        TxtTaxPer.Text           = TxtTaxName.Text = TXTEFFECTIVEDATE.Text = string.Empty;
        TxtSearch.Text           = string.Empty;
        TxtTaxName.Enabled       = true;
        SetInitialRow();
        ReportGrid(StrCondition);
    }