private void PrepareAndInsertDataForBinderAllotQtyDtl(string[] ChallanIds, string ChallanNo, string userId, int padcount) { foreach (var chr in ChallanIds) { string xData = string.Empty; bool result = default(bool); List <BinderAllotQuantityDtlMinimal> lstDtl = new List <BinderAllotQuantityDtlMinimal>(); BinderAllotQuantity objBinderAllotQuantity = new BinderAllotQuantity(); try { DataTable GetBinderAllotQtyDtl = objDbTrx.GetBinderAllotmentQtyByID(Convert.ToInt32(chr)); if (GetBinderAllotQtyDtl.Rows.Count > 0) { objBinderAllotQuantity.ID = Convert.ToInt32(GetBinderAllotQtyDtl.Rows[0]["ID"].ToString()); objBinderAllotQuantity.AllotmentCode = GetBinderAllotQtyDtl.Rows[0]["BINDER_ALLOT_CODE"].ToString(); objBinderAllotQuantity.BookCode = GetBinderAllotQtyDtl.Rows[0]["BOOK_CODE"].ToString(); objBinderAllotQuantity.BinderName = GetBinderAllotQtyDtl.Rows[0]["BinderName"].ToString(); objBinderAllotQuantity.BinderShortCode = GetBinderAllotQtyDtl.Rows[0]["BinderShortCode"].ToString(); objBinderAllotQuantity.LanguageName = GetBinderAllotQtyDtl.Rows[0]["LANGUAGE"].ToString(); objBinderAllotQuantity.BookName = GetBinderAllotQtyDtl.Rows[0]["BOOK_NAME"].ToString(); objBinderAllotQuantity.AllotmentDate = Convert.ToDateTime(GetBinderAllotQtyDtl.Rows[0]["ALLOTMENT_DATE"].ToString()).ToString("dd-MMM-yyyy").ToUpper(); objBinderAllotQuantity.TotQty = Convert.ToInt32(GetBinderAllotQtyDtl.Rows[0]["TOT_QTY"].ToString()); objBinderAllotQuantity.Lot = Convert.ToInt32(GetBinderAllotQtyDtl.Rows[0]["LOT"].ToString()); objBinderAllotQuantity.ReqQty = Convert.ToInt32(GetBinderAllotQtyDtl.Rows[0]["REQ_QTY"].ToString()); objBinderAllotQuantity.QtyIssued = Convert.ToInt32(GetBinderAllotQtyDtl.Rows[0]["QTY_ISSUED"].ToString()); objBinderAllotQuantity.SaveStatus = Convert.ToInt16(GetBinderAllotQtyDtl.Rows[0]["STATUS"].ToString()); } if (objBinderAllotQuantity != null && objBinderAllotQuantity.ID > default(int)) { int StartNo = 1; int EndNo = objBinderAllotQuantity.ReqQty; for (int iCnt = StartNo; iCnt <= EndNo; iCnt++) { var code = string.Format("{0}{1}", objBinderAllotQuantity.AllotmentCode, Convert.ToInt64(iCnt.ToString().PadLeft((padcount + 1), '0')).ToString().PadLeft(3, '0')); lstDtl.Add(new BinderAllotQuantityDtlMinimal() { //BINDER_ALLOT_ID = objBinderAllotQuantity.ID, BINDER_ALLOT_CODE = code, //BINDER_SHORT_CODE = objBinderAllotQuantity.BinderShortCode, STICKER_CODE = iCnt.ToString().PadLeft((padcount + 1), '0'), //CHALLAN_ID = default(int), //BOOK_CODE = objBinderAllotQuantity.BookCode, //SCANNED_STATUS = default(int), //CREATED_BY = userId, }); } if (lstDtl.Count() > default(int)) { xData = Utility.CreateXmlTraditional(Utility.ToDataTable <BinderAllotQuantityDtlMinimal>(lstDtl)).InnerXml; /*try * { * if (!System.IO.Directory.Exists(Server.MapPath("~/Logs/XML/"))) * System.IO.Directory.CreateDirectory(Server.MapPath("~/Logs/XML/")); * * System.IO.File.WriteAllText(string.Format("{0}{1}.txt", Server.MapPath("~/Logs/XML/"), DateTime.Now.ToString("ddMMyyyyHHmmss")), xData); * } * catch { }*/ result = objDbTrx.BinderAllotmentDtlInsert(objBinderAllotQuantity.ID, objBinderAllotQuantity.BinderShortCode, default(int), objBinderAllotQuantity.BookCode, default(int), userId, xData); } } } catch (Exception ex) { objDbTrx.SaveSystemErrorLog(ex, Request.UserHostAddress); } } }