public DataTable fillTempBookData(string bookcode, string flag) { DataTable dt = new DataTable(); DataTable tempGetData = new DataTable(); DataColumn colTax = new DataColumn(); colTax.DataType = System.Type.GetType("System.String"); colTax.ColumnName = "Rate"; DataColumn Discount = new DataColumn(); Discount.DataType = System.Type.GetType("System.String"); Discount.ColumnName = "Discount"; DataColumn AdditionalDiscount = new DataColumn(); AdditionalDiscount.DataType = System.Type.GetType("System.String"); AdditionalDiscount.ColumnName = "AdditionalDiscount"; DataColumn Amount = new DataColumn(); Amount.DataType = System.Type.GetType("System.String"); Amount.ColumnName = "Amount"; if (Session["tempDCData"] == null) { //CREATE NEW DATATABLE //ADD COLUMNS IN DATATABLE dt.Columns.Add("DCDetailID"); dt.Columns.Add("BookId"); dt.Columns.Add("BookCode"); dt.Columns.Add("BookName"); //dt.Columns.Add("BookType"); dt.Columns.Add("Standard"); dt.Columns.Add("Medium"); dt.Columns.Add("Quantity"); dt.Columns.Add("GivedQty"); dt.Columns.Add("RemainQty"); dt.Columns.Add("DeliveryDate"); dt.Columns.Add(colTax); dt.Columns.Add(Amount); dt.Columns.Add(Discount); dt.Columns.Add(AdditionalDiscount); //ADD DATA AS PER COLUMNS //Books _objBooks = new Books(); } else { dt = (DataTable)Session["tempDCData"]; } if (flag == "set") { tempGetData = BookSetDetails.Get_BookSetDetailsOn_SetID_ForDC((Convert.ToInt32(DDLSelectSet.SelectedItem.Value)), srate).Tables[0]; } else if (flag == "get") { try { tempGetData = DCDetails.GetDCDatilsByCode(bookcode, "documentno").Tables[0]; } catch { } } else { tempGetData = Books.Get_BooksMasterForDC(bookcode, srate).Tables[0]; Isblock = (Convert.ToBoolean(tempGetData.Rows[0]["IsBlock"].ToString())); } foreach (DataRow row in tempGetData.Rows) { price = row["SellingPrice"].ToString(); amt = Convert.ToDecimal(Qty) * Convert.ToDecimal(price); if (dt.Rows.Count != 0) { DataView dv = new DataView(dt); dv.RowFilter = "BookCode = '" + row["BookCode"].ToString() + "'"; int i = 0; price = row["SellingPrice"].ToString(); amt = Convert.ToDecimal(Qty) * Convert.ToDecimal(price); foreach (DataRowView row1 in dv) { i++; } if (i == 0) { DataSet ds = DCMaster.Get_Discount_On_CusomerAND_Booktype(txtcustomer.Text.ToString() + "!" + Session["FY"].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; } if (flag == "get") { Qty = row["Quantity"].ToString(); rqty = row["RemainQty"].ToString(); gqty = row["GivedQty"].ToString(); dcid = row["DCDetailID"].ToString(); string EDate = row["DeliveryDate"].ToString(); EDate = EDate.Split('/')[1] + "/" + EDate.Split('/')[0] + "/" + EDate.Split('/')[2]; Delidate = Convert.ToDateTime(EDate); price = row["SellingPrice"].ToString(); amt = Convert.ToDecimal(row["Amount"].ToString()); discount = Convert.ToDecimal(row["Discount"].ToString()); } dt.Rows.Add(dcid, row["Bookid"].ToString(), row["BookCode"].ToString(), row["BookName"].ToString(), row["Standard"].ToString(), row["Medium"].ToString(), Qty, gqty, rqty, Delidate.ToString("dd/MM/yyyy"), String.Format("{0:0.00}", Convert.ToDecimal(row["SellingPrice"].ToString())), String.Format("{0:0.00}", Convert.ToDecimal(amt)), String.Format("{0:0.00}", Convert.ToDecimal(discount)), String.Format("{0:0.00}", Convert.ToDecimal(Adddiscount))); } } else { DataSet ds = DCMaster.Get_Discount_On_CusomerAND_Booktype(txtcustomer.Text.ToString() + "!" + Session["FY"].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; } if (flag == "get") { Qty = row["Quantity"].ToString(); rqty = row["RemainQty"].ToString(); gqty = row["GivedQty"].ToString(); dcid = row["DCDetailID"].ToString(); string EDate = row["DeliveryDate"].ToString(); EDate = EDate.Split('/')[1] + "/" + EDate.Split('/')[0] + "/" + EDate.Split('/')[2]; Delidate = Convert.ToDateTime(EDate); price = row["SellingPrice"].ToString(); amt = Convert.ToDecimal(row["Amount"].ToString()); discount = Convert.ToDecimal(row["Discount"].ToString()); } dt.Rows.Add(dcid, row["Bookid"].ToString(), row["BookCode"].ToString(), row["BookName"].ToString(), row["Standard"].ToString(), row["Medium"].ToString(), Qty, gqty, rqty, Delidate.ToString("dd/MM/yyyy"), String.Format("{0:0.00}", Convert.ToDecimal(row["SellingPrice"].ToString())), String.Format("{0:0.00}", Convert.ToDecimal(amt)), String.Format("{0:0.00}", Convert.ToDecimal(discount)), String.Format("{0:0.00}", Convert.ToDecimal(Adddiscount))); } } return(dt); }