Exemplo n.º 1
0
    protected void GrdExpencesDetails_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        try
        {
            if (ViewState["CurrentTable"] != null)
            {
                int       id = e.RowIndex;
                DataTable dt = (DataTable)ViewState["CurrentTable"];

                dt.Rows.RemoveAt(id);

                if (dt.Rows.Count > 0)
                {
                    GrdExpencesDetails.DataSource = dt;
                    ViewState["CurrentTable"]     = dt;
                    GrdExpencesDetails.DataBind();
                }
                else
                {
                    SetInitialRowExpence();
                }
            }
        }
        catch (Exception)
        {
            throw;
        }
    }
Exemplo n.º 2
0
    public void SetInitialRowExpence()
    {
        try
        {
            DataTable dtTable = new DataTable();
            DataRow   dr;
            dtTable.Columns.Add("#", typeof(int));
            dtTable.Columns.Add("Particular", typeof(String));
            dtTable.Columns.Add("Qty", typeof(decimal));
            dtTable.Columns.Add("Rate", typeof(decimal));
            dtTable.Columns.Add("Amount", typeof(decimal));
            dtTable.Columns.Add("Remark", typeof(String));

            dr = dtTable.NewRow();

            dr["#"]          = 0;
            dr["Particular"] = string.Empty;
            dr["Qty"]        = 0;
            dr["Rate"]       = 0;
            dr["Amount"]     = 0;;
            dr["Remark"]     = string.Empty;

            dtTable.Rows.Add(dr);
            ViewState["CurrentTable"]     = dtTable;
            GrdExpencesDetails.DataSource = dtTable;
            GrdExpencesDetails.DataBind();
        }
        catch (Exception ex) { throw new Exception(ex.Message); }
    }
Exemplo n.º 3
0
    protected void GrdReport_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        try
        {
            switch (e.CommandName)
            {
            case ("Select"):
            {
                if (Convert.ToInt32(e.CommandArgument) != 0)
                {
                    ViewState["EditID"] = Convert.ToInt32(e.CommandArgument);

                    DS = Obj_EH.GetExpenceHeadToEdit(Convert.ToInt32(e.CommandArgument), out StrError);

                    if (DS.Tables.Count > 0 && DS.Tables[0].Rows.Count > 0)
                    {
                        txtEHNo.Text                 = DS.Tables[0].Rows[0]["ExpenceNo"].ToString();
                        txtFromDate.Text             = DS.Tables[0].Rows[0]["ExpenceDate"].ToString();
                        ddlProjectName.SelectedValue = DS.Tables[0].Rows[0]["PropertyId"].ToString();

                        if (DS.Tables.Count > 0 && DS.Tables[1].Rows.Count > 0)
                        {
                            GrdExpencesDetails.DataSource = DS.Tables[1];
                            GrdExpencesDetails.DataBind();
                            ViewState["CurrentTable"] = DS.Tables[1];
                        }
                        else
                        {
                            SetInitialRowExpence();
                        }
                        if (!FlagEdit)
                        {
                            BtnUpdate.Visible = true;
                        }
                        BtnSave.Visible = false;
                    }
                    else
                    {
                        // Makefromempty();
                    }
                }

                break;
            }
            }
        }
        catch (Exception ex)
        {
            Obj_Comm.ShowPopUpMsg("Please try after Some Time..!", this.Page);
        }
    }
Exemplo n.º 4
0
    protected void ImgAddRrow_Click(object sender, ImageClickEventArgs e)
    {
        int rowIndex = 0;

        if (Convert.ToInt32(ddlProjectName.SelectedValue) > 0)
        {
            if (ViewState["CurrentTable"] != null)
            {
                DataTable dtCurrentTable = (DataTable)ViewState["CurrentTable"];
                DataTable DTTEMP         = dtCurrentTable.Clone();
                DataRow   dtTableRow     = null;
                #region

                if (GrdExpencesDetails.Rows[0].Cells[1].Text.Equals(" ") || string.IsNullOrEmpty(GrdExpencesDetails.Rows[0].Cells[1].Text))
                {
                    dtCurrentTable.Rows.RemoveAt(0);
                }

                for (int i = 0; i < GrdExpencesDetails.Rows.Count; i++)
                {
                    TextBox txtParticular = (TextBox)GrdExpencesDetails.Rows[i].Cells[2].FindControl("txtParticular");
                    TextBox txtQty        = (TextBox)GrdExpencesDetails.Rows[i].Cells[3].FindControl("txtQty");
                    TextBox txtRate       = (TextBox)GrdExpencesDetails.Rows[i].Cells[4].FindControl("txtRate");
                    TextBox txtAmount     = (TextBox)GrdExpencesDetails.Rows[i].Cells[5].FindControl("txtAmount");
                    TextBox txtRemark     = (TextBox)GrdExpencesDetails.Rows[i].Cells[6].FindControl("txtRemark");

                    dtTableRow = DTTEMP.NewRow();
                    dtTableRow["Particular"] = txtParticular.Text;
                    dtTableRow["Qty"]        = txtQty.Text;
                    dtTableRow["Rate"]       = txtRate.Text;
                    dtTableRow["Amount"]     = txtAmount.Text;
                    dtTableRow["Remark"]     = txtRemark.Text;
                    rowIndex++;
                    DTTEMP.Rows.Add(dtTableRow);
                }
                if (DTTEMP.Rows.Count > 0)
                {
                    dtCurrentTable = DTTEMP;
                }
                dtTableRow = null;
                #endregion

                if (dtCurrentTable.Rows.Count > 0)
                {
                    dtTableRow = dtCurrentTable.NewRow();

                    dtTableRow["#"]          = 0;
                    dtTableRow["Particular"] = "";
                    dtTableRow["Qty"]        = 0;
                    dtTableRow["Rate"]       = 0;
                    dtTableRow["Amount"]     = 0;
                    dtTableRow["Remark"]     = "";
                    dtCurrentTable.Rows.Add(dtTableRow);

                    ViewState["CurrentTable"]     = dtCurrentTable;
                    GrdExpencesDetails.DataSource = dtCurrentTable;
                    GrdExpencesDetails.DataBind();

                    // Makecontrolempty();
                }
            }
        }
    }