Ejemplo n.º 1
0
    protected void btnget_Click(object sender, EventArgs e)
    {
        lblviewCNNo.Text = txtCnno.Text.Trim();
        CNNo             = Convert.ToInt32(txtCnno.Text.Trim());
        // Bindgrdcn();
        //grdcn.DataSource = CreditNote.PrintCN(CNNo);
        //grdcn.DataBind();
        DataSet grid = new DataSet();

        grid = CreditNote.EditCN(Convert.ToInt32(strFY), CNNo);
        grdBookDetails.DataSource = grid;
        grdBookDetails.DataBind();
        Session["tempDCData1"] = grid.Tables[0];
        DataSet ds6 = new DataSet();

        ds6 = CreditNote.PrintCN(Convert.ToInt32(strFY), CNNo);

        if (ds6.Tables[1].Rows.Count > 0)
        {
            txtCNDate.Text      = ds6.Tables[1].Rows[0]["CNDate"].ToString();
            lblCustN.Text       = ds6.Tables[1].Rows[0]["CustName"].ToString();
            lbledit.Text        = Convert.ToInt32(ds6.Tables[1].Rows[0]["IsEdit"]).ToString();
            txtGCN.Text         = ds6.Tables[1].Rows[0]["GCN"].ToString();
            txtSCN.Text         = ds6.Tables[1].Rows[0]["SCN"].ToString();
            txtlRNO.Text        = ds6.Tables[1].Rows[0]["LrNo"].ToString();
            lbltransporter.Text = ds6.Tables[1].Rows[0]["TransportName"].ToString();
            lblflagdc.Text      = ds6.Tables[1].Rows[0]["Flag"].ToString();
            CustCode            = ds6.Tables[1].Rows[0]["CustCode"].ToString();
            if (ds6.Tables[1].Rows[0]["IsExciseApplicable"].ToString() == "1")
            {
                ISExcise.Checked = true;
            }
            else
            {
                ISExcise.Checked = false;
            }
        }

        if (lbledit.Text == "0")
        {
            btn_Save.Enabled     = false;
            btn_Save.BorderColor = System.Drawing.Color.Red;
            btn_Save.ToolTip     = "Record Editing Locked";
        }
        else
        {
            btn_Save.BorderColor = System.Drawing.Color.Green;
            btn_Save.Enabled     = true;
            btn_Save.ToolTip     = "";
        }

        btn_Save.Visible = true;
        PnlAddbk.Visible = true;

        PnlPrint.Visible = false;
        btnPrint.Visible = false;

        grdBookDetails.Focus();
        //UpdatePanel1.Update();
    }
Ejemplo n.º 2
0
    protected void grdBookDetails_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        cndate = txtCNDate.Text.Split('/')[2] + "/" + txtCNDate.Text.Split('/')[1] + "/" + txtCNDate.Text.Split('/')[0];
        cndt   = Convert.ToDateTime(cndate);

        int r1    = grdBookDetails.Rows.Count;
        int cntr1 = 0;

        if (Session["UserName"] != null)
        {
            CNNo = Convert.ToInt32(txtCnno.Text.Trim());

            CreditNote _obedtcn = new CreditNote();
            LedgerCN   _obedtld = new LedgerCN();

            try
            {
                foreach (GridViewRow Row in grdBookDetails.Rows)
                {
                    CheckBox chkBxSelect = (CheckBox)Row.FindControl("chkBxSelect");

                    if (chkBxSelect != null)
                    {
                        if (chkBxSelect.Checked == true)
                        {
                            // bool chkbx = ((CheckBox)Row.FindControl("chkBxSelect")).;

                            string RQty = (((TextBox)Row.FindControl("txtretquty")).Text.Trim());
                            //string DfQty = ((TextBox)Row.FindControl("txtdefquty")).Text;
                            string CrQty = (((TextBox)Row.FindControl("txtquty")).Text.Trim());
                            string AtID  = (((Label)Row.FindControl("lblDAutoID")).Text.Trim());

                            _obedtcn.AutoID = Convert.ToInt32(AtID);
                            _obedtcn.CNNo   = CNNo;
                            //_obedtcn.CustCode = (DDLCustomer.SelectedValue);
                            _obedtcn.CustCode     = CustCode; //txtcustomer.Text.Trim().ToString();
                            _obedtcn.BookCode     = (((Label)Row.FindControl("lblBookCode")).Text.Trim());
                            _obedtcn.Rate         = Convert.ToDecimal(((TextBox)Row.FindControl("txtrate")).Text.Trim());
                            _obedtcn.Discount     = Convert.ToDecimal(((TextBox)Row.FindControl("txtDiscount")).Text.Trim());
                            _obedtcn.ReturnQty    = Convert.ToInt32(CrQty);
                            _obedtcn.Comment      = (((TextBox)Row.FindControl("txtcmmt")).Text.Trim());
                            _obedtcn.IsActive     = true;
                            _obedtcn.UpdatedBy    = Session["UserName"].ToString();
                            _obedtcn.Flag         = (((Label)Row.FindControl("lblflag")).Text.Trim());
                            _obedtcn.TotReturnQty = Convert.ToInt32(RQty);
                            _obedtcn.DefectQty    = 0;
                            _obedtcn.IsDeleted    = true;
                            _obedtcn.strFY        = Convert.ToInt32(strFY);
                            _obedtcn.CNDate       = cndt;
                            _obedtld.CNDate       = cndt;
                            if (txtGCN.Text != "")
                            {
                                _obedtcn.GCN = Convert.ToInt32(txtGCN.Text);
                            }
                            else
                            {
                                _obedtcn.GCN = 0;
                            }
                            if (txtSCN.Text != "")
                            {
                                _obedtcn.SCN = Convert.ToInt32(txtSCN.Text);
                            }
                            else
                            {
                                _obedtcn.SCN = 0;
                            }
                            _obedtcn.LrNo          = txtlRNO.Text.Trim().ToString();
                            _obedtcn.TransportName = lbltransporter.Text.Trim().ToString();
                            _obedtcn.Update_CN(Convert.ToInt32(strFY));
                            cntr1 = cntr1 + 1;
                        }
                    }
                }
                //_obedtcn.AutoID = Convert.ToInt32(AtID);
                //_obedtcn.CNNo = CNNo;
                //_obedtcn.CustCode = (DDLCustomer.SelectedValue);
                //_obedtcn.BookCode = ((Label)grdBookDetails.Rows[e.NewEditIndex].FindControl("lblBookCode")).Text;
                //_obedtcn.Rate = Convert.ToDecimal(((TextBox)grdBookDetails.Rows[e.NewEditIndex].FindControl("txtrate")).Text.Trim());
                //_obedtcn.Discount = Convert.ToDecimal(((TextBox)grdBookDetails.Rows[e.NewEditIndex].FindControl("txtDiscount")).Text.Trim());
                //_obedtcn.ReturnQty = Convert.ToInt32(CrQty);
                //_obedtcn.Comment = ((TextBox)grdBookDetails.Rows[e.NewEditIndex].FindControl("txtcmmt")).Text;
                //_obedtcn.IsActive = true;
                //_obedtcn.UpdatedBy = Session["UserName"].ToString();
                //_obedtcn.Flag = ((Label)grdBookDetails.Rows[e.NewEditIndex].FindControl("lblflag")).Text;
                //_obedtcn.TotReturnQty = Convert.ToInt32(RQty);
                //_obedtcn.DefectQty = 0;
                //_obedtcn.IsDeleted = false;

                //_obedtcn.Update_CN();

                if (cntr1 == 0)
                {
                    MessageBox("Select Record To Delete");
                }
                if (cntr1 > 0)
                {
                    _obedtld.CNNo   = CNNo;
                    _obedtld.strFY  = Convert.ToInt32(Convert.ToInt32(strFY));
                    _obedtld.CNDate = cndt;
                    _obedtld.Ledger_CN();

                    MessageBox("Record Deleted Successfully");
                    CustCode         = null;
                    txtcustomer.Text = "";
                    lblCustName.Text = "";
                    // Bindgrdcn();
                    DataSet grid = new DataSet();
                    grid = CreditNote.EditCN(Convert.ToInt32(strFY), CNNo);
                    grdBookDetails.DataSource = grid;
                    grdBookDetails.DataBind();
                    quantity = 0;
                    tamount  = 0;

                    DataTable dt1 = new DataTable();
                    dt1 = DCReturnBook.GetCustAddress(cust, "CNCustlist").Tables[0];
                    if (dt1.Rows.Count > 0)
                    {
                        lblCNNo.Text        = (txtCnno.Text.Trim());
                        lblCustName1.Text   = dt1.Rows[0]["CustName"].ToString();
                        lblCustAddress.Text = dt1.Rows[0]["Address"].ToString();
                    }
                    PnlAddbk.Visible = true;
                    btn_Save.Visible = true;
                    PnlPrint.Visible = false;
                    btnPrint.Visible = false;
                }
            }
            catch
            {
            }
            grdBookDetails.Focus();
        }
    }