public ActionResult Index(Int32?BinderAllotmentId) { ViewBag.Active = "TrxBinderAllotmentQuantityView"; BinderAllotQuantity objBinderAllotQuantity = new BinderAllotQuantity(); if (BinderAllotmentId == null || BinderAllotmentId <= 0) { objBinderAllotQuantity.AllotmentDate = DateTime.Now.ToString("dd-MMM-yyyy").ToUpper(); //objBinderAllotQuantity.AllotmentCode = "BLR" + (DateTime.Now.Month >= 4 ? DateTime.Now.Year.ToString().Substring(2) + (Convert.ToInt32(DateTime.Now.Year.ToString().Substring(2)) + 1) + "XXXXXXXX" : (Convert.ToInt32(DateTime.Now.Year.ToString().Substring(2)) - 1) + DateTime.Now.Year.ToString().Substring(2) + "XXXXXXXX").ToString(); objBinderAllotQuantity.AllotmentCode = string.Format("{0}{1}", GlobalSettings.oAcademicYear.PFX_BINDER, new String('X', GlobalSettings.oAcademicYear.FormatNumberPaddingCount)); objBinderAllotQuantity.ID = -1; } else if (BinderAllotmentId > 0) { try { DataTable GetBinderAllotQtyDtl = objDbTrx.GetBinderAllotmentQtyByID(Convert.ToInt32(BinderAllotmentId)); if (GetBinderAllotQtyDtl.Rows.Count > 0) { objBinderAllotQuantity.ID = Convert.ToInt32(GetBinderAllotQtyDtl.Rows[0]["ID"].ToString()); objBinderAllotQuantity.AllotmentCode = GetBinderAllotQtyDtl.Rows[0]["BINDER_ALLOT_CODE"].ToString(); objBinderAllotQuantity.BinderId = Convert.ToInt16(GetBinderAllotQtyDtl.Rows[0]["BINDER_ID"].ToString()); objBinderAllotQuantity.LanguageId = GetBinderAllotQtyDtl.Rows[0]["LANGUAGE_ID"].ToString(); objBinderAllotQuantity.ChallanCategoryId = Convert.ToInt16(GetBinderAllotQtyDtl.Rows[0]["CHALLAN_CATEGORY_ID"].ToString()); objBinderAllotQuantity.BookCode = GetBinderAllotQtyDtl.Rows[0]["BOOK_CODE"].ToString(); objBinderAllotQuantity.BinderName = GetBinderAllotQtyDtl.Rows[0]["BinderName"].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()); } } catch (Exception ex) { TempData["AppMessage"] = "Some Error has occurred while performing your activity. Please contact the System Administrator for further assistance."; objDbTrx.SaveSystemErrorLog(ex, Request.UserHostAddress); } } return(View(objBinderAllotQuantity)); }
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); } } }