示例#1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        CustCode = txtcustomer.Text.ToString().Split(':')[0].Trim();


        if (Session["FY"] != null)
        {
            strChetanaCompanyName = Session["ChetanaCompanyName"].ToString();
            strFY = Session["FY"].ToString();
        }
        else
        {
            Session.Clear();
        }
        //Response.Write(strFY);


        if (!Page.IsPostBack)
        {
            BindDDLstd();
            Txtgcn.Focus();
            // Panel3.Visible = false;
            //Panelview.Visible = false;
            // Pnlcustdet.Visible = false;
            Panel2.Visible = false;
            // btngetRec.Visible = true;
            btnSave.Visible        = true;
            btnPrint.Visible       = false;
            PnlPrint.Visible       = false;
            Session["tempDCData1"] = null;
            txtCNDate.Text         = DateTime.Now.ToString("dd/MM/yyyy");
        }
        //else
        //{
        //}
    }
示例#2
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        cndate = txtCNDate.Text.Split('/')[2] + "/" + txtCNDate.Text.Split('/')[1] + "/" + txtCNDate.Text.Split('/')[0];
        cndt   = Convert.ToDateTime(cndate);

        bool flag  = false;
        int  flag1 = 0;
        int  flag2 = 0;

        CNNo = 0;
        int GCN;
        int SCN;

        if (Txtgcn.Text.Trim() == "")
        {
            Txtgcn.Text = "0";
        }
        if (Txtscn.Text.Trim() == "")
        {
            Txtscn.Text = "0";
        }

        GCN = Convert.ToInt32(Txtgcn.Text.Trim());
        SCN = Convert.ToInt32(Txtscn.Text.Trim());
        if (Session["UserName"] != null)
        {
            DCReturnBook _obdcrtbk = new DCReturnBook();
            CreditNote   _obcn     = new CreditNote();
            LedgerCN     _oblcn    = new LedgerCN();
            try
            {
                foreach (GridViewRow Row in Grd2.Rows)
                {
                    string RQty = ((TextBox)Row.FindControl("txtreturn")).Text.Trim();
                    int    qty  = (Convert.ToInt32(RQty));
                    string cmt  = ((TextBox)Row.FindControl("txtcmmt")).Text.Trim();

                    if (qty > 0)
                    {
                        flag1 = flag1 + 1;
                        if (cmt != "")
                        {
                            flag2 = flag2 + 1;
                        }
                        else
                        {
                        }
                    }
                }

                if (flag1 == 0)
                {
                    MessageBox("Please Enter Return Quantity");
                    Panel2.Visible = true;
                }
                if (flag1 > flag2)
                {
                    MessageBox("Please Enter Comment For Respective Quantity");
                    Panel2.Visible = true;
                }

                if (flag1 == flag2)
                {
                    CNNo         = Convert.ToInt32(CreditNote.GetCNNo(Convert.ToInt32(strFY)));
                    lblCNNo.Text = CreditNote.GetCNNo(Convert.ToInt32(strFY));
                    foreach (GridViewRow Row in Grd2.Rows)
                    {
                        _obdcrtbk.DCReturnBkID = 0;
                        _obdcrtbk.CustCode     = CustCode;
                        _obdcrtbk.BookCode     = (((Label)Row.FindControl("lblbkcode")).Text.Trim());
                        string RQty  = ((TextBox)Row.FindControl("txtreturn")).Text.Trim();
                        int    rqty1 = Convert.ToInt32(RQty);
                        _obdcrtbk.ReturnQty = Convert.ToInt32(RQty);
                        string cmt = ((TextBox)Row.FindControl("txtcmmt")).Text.Trim();
                        _obdcrtbk.Comment   = ((TextBox)Row.FindControl("txtcmmt")).Text.Trim();
                        _obdcrtbk.CreatedBy = Session["UserName"].ToString();
                        _obdcrtbk.Flag      = "DC";
                        string dqty = ((TextBox)Row.FindControl("txtDefect")).Text.Trim();
                        // _obdcrtbk.DefectQty = Convert.ToInt32(dqty);
                        _obdcrtbk.DefectQty = 0;
                        _obdcrtbk.strFY     = Convert.ToInt32(strFY);

                        if (RdbtnYN.SelectedValue == "1")
                        {
                            _obcn.AutoID   = 0;
                            _obcn.CNNo     = CNNo;
                            _obcn.CustCode = CustCode;
                            _obcn.BookCode = (((Label)Row.FindControl("lblbkcode")).Text.Trim());
                            _obcn.Rate     = Convert.ToDecimal(((DropDownList)Row.FindControl("DDLR")).SelectedValue);
                            _obcn.Discount = Convert.ToDecimal(((DropDownList)Row.FindControl("DDLD")).SelectedValue);

                            string CNqty = ((TextBox)Row.FindControl("txtCN")).Text.Trim();
                            _obcn.ReturnQty    = Convert.ToInt32(CNqty);
                            _obcn.DefectQty    = 0;
                            _obcn.TotReturnQty = Convert.ToInt32(RQty);
                            _obcn.Comment      = ((TextBox)Row.FindControl("txtcmmt")).Text.Trim();
                            _obcn.IsActive     = true;
                            _obcn.GCN          = GCN;
                            _obcn.SCN          = SCN;
                            _obcn.CreatedBy    = Session["UserName"].ToString();
                            _obcn.Flag         = "DC";
                            _obcn.strFY        = Convert.ToInt32(strFY);
                            _obcn.CNDate       = cndt;

                            _obcn.TransportName = lbltransporter.Text.ToString();
                            _obcn.LrNo          = txtlrno.Text.ToString();
                            _obcn.Remark1       = "";
                            _obcn.Remark2       = "";
                            _obcn.Remark3       = "";
                            _obcn.Remark4       = "";
                            _obcn.Remark5       = "";
                        }
                        else
                        {
                        }

                        if (rqty1 > 0 && cmt != "")
                        {
                            _obdcrtbk.Save_DC_ReturnBook(Convert.ToInt32(strFY));

                            if (RdbtnYN.SelectedValue == "1")
                            {
                                _oblcn.CNNo   = CNNo;
                                _oblcn.strFY  = Convert.ToInt32(strFY);
                                _oblcn.CNDate = cndt;
                                _obcn.Save_CN(Convert.ToInt32(strFY));
                            }
                            else
                            {
                            }
                            flag = true;

                            //bind grid to display printdata
                            Bindgrdcn();
                        }
                        else
                        {
                        }
                    }
                }

                if (flag)
                {
                    try
                    {
                        if (RdbtnYN.SelectedValue == "1")
                        {
                            _oblcn.Ledger_CN();
                            MessageBox(Constants.save + "\\r\\n CreditNote No: " + CNNo);
                            //BindGrd2();
                            PnlPrint.Visible    = true;
                            btnPrint.Visible    = true;
                            btnaddBooks.Visible = false;
                            txtcustomer.Enabled = true;
                        }
                        else
                        if (RdbtnYN.SelectedValue == "0")
                        {
                            MessageBox(Constants.save);
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox("Error : " + ex.Message.ToString());
                        clearall();
                        Txtgcn.Focus();
                    }
                    Panel2.Visible = false;
                    // RdbtnYN.SelectedIndex = 0;
                    // txtcustomer.Text = "";
                    //lblCustName.Text = "";
                }
            }
            catch (Exception ex)
            {
                MessageBox("Error : " + ex.Message.ToString());
            }
        }
    }