Example #1
0
    protected void Grdcustview_RowEditing(object sender, GridViewEditEventArgs e)
    {
        try
        {
            string CustCode = ((Label)GrdCustview.Rows[e.NewEditIndex].FindControl("lblCustCode1")).Text;
            string DC       = ((Label)GrdCustview.Rows[e.NewEditIndex].FindControl("lblDC1")).Text;

            if (DC == "Y")
            {
                DataTable dt5 = new DataTable();
                dt5 = DCReturnBook.GetCustAddress(CustCode, "RtdBkCustlist").Tables[0];

                if (dt5.Rows.Count > 0)
                {
                    lbl5CustName.Text    = dt5.Rows[0]["CustName"].ToString();
                    lbl5CustAddress.Text = dt5.Rows[0]["Address"].ToString();
                }
                Grd5.DataSource = CreditNote.Get_DC_CNBook(Convert.ToInt32(strFY), CustCode, "DCRTDBookAll").Tables[0];
                Grd5.DataBind();

                PnlCustview.Visible     = false;
                Pnl5CustDetails.Visible = true;
                Pnl5.Visible            = true;
                Pnl4CustDetails.Visible = false;
                Pnl4.Visible            = false;
            }
            else
            if (DC == "N")
            {
                DataTable dt4 = new DataTable();
                dt4 = DCReturnBook.GetCustAddress(CustCode, "RtdBkCustlist").Tables[0];

                if (dt4.Rows.Count > 0)
                {
                    lbl4CustName.Text    = dt4.Rows[0]["CustName"].ToString();
                    lbl4CustAddress.Text = dt4.Rows[0]["Address"].ToString();
                }

                Grd4.DataSource = CreditNote.Get_DC_CNBook(Convert.ToInt32(strFY), CustCode, "DCRTDBook").Tables[0];
                Grd4.DataBind();

                PnlCustview.Visible     = false;
                Pnl5CustDetails.Visible = false;
                Pnl5.Visible            = false;
                Pnl4CustDetails.Visible = true;
                Pnl4.Visible            = true;
            }
        }
        catch
        {
        }
    }
Example #2
0
    public DataTable fillTempBookData(string bookcode, string custCode)
    {
        DataTable  dt          = new DataTable();
        DataTable  tempGetData = new DataTable();
        DataColumn Discount    = new DataColumn();

        Discount.DataType   = System.Type.GetType("System.String");
        Discount.ColumnName = "Discount";

        DataColumn Amount = new DataColumn();

        Amount.DataType   = System.Type.GetType("System.String");
        Amount.ColumnName = "Amount";

        if (Session["tempDCData1"] == null)
        {
            //CREATE NEW DATATABLE
            //ADD COLUMNS IN DATATABLE
            dt.Columns.Add("BookCode");
            dt.Columns.Add("BookName");
            dt.Columns.Add("Standard");
            dt.Columns.Add("Medium");
            //dt.Columns.Add("Qty");
            dt.Columns.Add("ReturnedQty");
            dt.Columns.Add("AvailableQty");
            //dt.Columns.Add("CN");
            dt.Columns.Add(Amount);
            dt.Columns.Add(Discount);
            //dt.Columns.Add("AddedrQty");
            //dt.Columns.Add("AddeCnQty");
            dt.Columns.Add("Comment");
            //ADD DATA AS PER COLUMNS
            //Books _objBooks = new Books();
        }
        else
        {
            dt = (DataTable)Session["tempDCData1"];
        }

        if (lblflagdc.Text == "DC")
        {
            tempGetData = CreditNote.Get_DC_CNBook(Convert.ToInt32(strFY), custCode, bookcode).Tables[0];
        }
        else
        {
            tempGetData = Books.Get_BooksMasterForDC(bookcode, "").Tables[0];
        }
        foreach (DataRow row in tempGetData.Rows)
        {
            //string price = row["Amount"].ToString();
            // decimal amt =0.00m;
            // if (price == "")
            // {
            //     price = "0";
            // }
            // amt = Convert.ToDecimal(quantity) * Convert.ToDecimal(price);

            if (dt.Rows.Count != 0)
            {
                DataView dv = new DataView(dt);
                dv.RowFilter = "BookCode = '" + row["BookCode"].ToString() + "'";
                int i = 0;
                //price = row["Amount"].ToString();
                //amt = Convert.ToDecimal(quantity) * Convert.ToDecimal(price);
                foreach (DataRowView row1 in dv)
                {
                    i++;
                }

                if (i == 0)
                {
                    //DataSet ds = DCMaster.Get_Discount_On_CusomerAND_Booktype(txtcustomer.Text.ToString(), row["BookCode"].ToString());

                    //if (ds.Tables[0].Rows.Count > 0)
                    //{
                    //    discount = Convert.ToDecimal(ds.Tables[0].Rows[0][0]);
                    //    Adddiscount = Convert.ToDecimal(ds.Tables[0].Rows[0][1]);
                    //    Tdiscount = amt * (discount / 100);
                    //    amt = amt - Tdiscount;
                    //}
                    dt.Rows.Add(0, 0, 0, row["BookCode"].ToString(),
                                row["BookName"].ToString(), row["Medium"].ToString(), row["Standard"].ToString(),
                                // row["Qty"].ToString(),
                                txRetqty.Text.Trim().ToString(), 0,
                                txRetqty.Text.Trim().ToString(),
                                "0.00", "0.00", "0.00", "0.00", txtComment.Text, lblflagdc.Text.ToString(), "true", "true", DateTime.Now.ToString("MM/dd/yyyy"), "false");
                }
            }
            else
            {
                //  DataSet ds = DCMaster.Get_Discount_On_CusomerAND_Booktype(txtcustomer.Text.ToString(), row["BookCode"].ToString());

                //if (ds.Tables[0].Rows.Count > 0)
                //{
                //    discount = Convert.ToDecimal(ds.Tables[0].Rows[0][0]);
                //    Adddiscount = Convert.ToDecimal(ds.Tables[0].Rows[0][1]);
                //    //  Totaldiscount = Convert.ToDecimal(ds.Tables[0].Rows[0][2]);
                //    Tdiscount = amt * (discount / 100);
                //    amt = amt - Tdiscount;
                //}

                dt.Rows.Add(row["BookCode"].ToString(),
                            row["BookName"].ToString(), row["Standard"].ToString(), row["Medium"].ToString(),
                            // row["Qty"].ToString(),
                            row["ReturnedQty"].ToString(),
                            row["AvailableQty"].ToString(),
                            "0.00", "0.00", "0.00", txRetqty.Text, txRetqty.Text, txtComment.Text);
            }
        }
        Session["tempDCData1"] = dt;
        return(dt);
    }