public ApproveRejectAVTemplate(AdjustmentVoucher av, Employee clerk, Employee sup) { long InitiatedDate = (long)av.InitiatedDate; DateTime startTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc); DateTime InitiatedDate1 = startTime.AddMilliseconds(Convert.ToDouble(InitiatedDate)); string InitiatedDate2 = InitiatedDate1.ToString("dd MMM yyyy"); if (av.Reason == null) { this.body = "Dear " + clerk.Name + System.Environment.NewLine + System.Environment.NewLine + "Your adjustment voucher with id: " + av.Id + " dated " + InitiatedDate2 + " is " + av.Status + "." + System.Environment.NewLine + System.Environment.NewLine + "Thank you."; } else { this.body = "Dear " + clerk.Name + System.Environment.NewLine + System.Environment.NewLine + "Your adjustment voucher with id: " + av.Id + " dated " + InitiatedDate2 + " is " + av.Status + ". The reason provided is " + av.Reason + "." + System.Environment.NewLine + System.Environment.NewLine + "Thank you."; } }
public PendingManagerApprovalAVTemplate(AdjustmentVoucher av, Employee manager, Employee sup) { long InitiatedDate = (long)av.InitiatedDate; DateTime startTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc); DateTime InitiatedDate1 = startTime.AddMilliseconds(Convert.ToDouble(InitiatedDate)); string InitiatedDate2 = InitiatedDate1.ToString("dd MMM yyyy"); if (av.Reason == null) { this.body = "Dear " + manager.Name + System.Environment.NewLine + System.Environment.NewLine + "A new adjustment voucher submitted on " + InitiatedDate2 + " is pending your further action." + System.Environment.NewLine + System.Environment.NewLine + "Thank you." + System.Environment.NewLine + System.Environment.NewLine + "Store supervisor" + System.Environment.NewLine + sup.Name; } else { this.body = "Dear " + manager.Name + System.Environment.NewLine + System.Environment.NewLine + "A new adjustment voucher submitted on " + InitiatedDate2 + " is pending your further action. The reason provided by the supervisor is " + av.Reason + "." + System.Environment.NewLine + System.Environment.NewLine + "Thank you." + System.Environment.NewLine + System.Environment.NewLine + "Store supervisor" + System.Environment.NewLine + sup.Name; } }
public static void SeedEntities(ADProjectDb context) { StockInfo stockInfo = new StockInfo(); stockInfo.ItemCatalogue = context.ItemCatalogue.FirstOrDefault(); AdjustmentStatus adjustmentStatus = new AdjustmentStatus(); adjustmentStatus.Description = "APPROVED"; AdjustmentDetail adjustmentDetail = new AdjustmentDetail(); adjustmentDetail.ItemCatalogue = context.ItemCatalogue.FirstOrDefault(); AdjustmentVoucher adjustmentVoucher = new AdjustmentVoucher(); adjustmentVoucher.AdjustmentStatus = adjustmentStatus; adjustmentVoucher.AdjustmentDetail = new List <AdjustmentDetail>() { adjustmentDetail }; context.StockInfo.Add(stockInfo); context.AdjustmentStatus.Add(adjustmentStatus); context.AdjustmentDetail.Add(adjustmentDetail); context.AdjustmentVoucher.Add(adjustmentVoucher); context.SaveChanges(); }
public static void makeNewAdjustmentVoucher(List <MakeAdjustmentItem> adjustmentList) { AdjustmentVoucher adjustmentVoucher = new AdjustmentVoucher(); adjustmentVoucher.DateCreated = DateTime.Now; EntityCollection <AdjustmentVoucherDetail> voucherDetailsCollection = new EntityCollection <AdjustmentVoucherDetail>(); foreach (MakeAdjustmentItem item in adjustmentList) { Product p = ProductDAO.getSearchProductbyid(item.ItemNumber); double totalPrice = (double)p.AdjustmentVoucherPrice * item.Quantity; AdjustmentVoucherDetail avd = new AdjustmentVoucherDetail(); avd.ItemNumber = item.ItemNumber; avd.Status = item.Status.Equals("Excess") ? AdjustmentVoucherEFFacade.STATUS_DECREASE : AdjustmentVoucherEFFacade.STATUS_INCREASE; avd.TotalPrice = totalPrice; avd.Comment = item.Comment; avd.ApprovalStatus = AdjustmentVoucherEFFacade.APPROVAL_STATUS_PENDING; avd.Quantity = item.Quantity; voucherDetailsCollection.Add(avd); } adjustmentVoucher.AdjustmentVoucherDetails = voucherDetailsCollection; AdjustmentVoucherEFFacade.addNewAdjustVoucherWithArrayVoucherDetails(adjustmentVoucher); }
public bool UpdateVoucherStatuc([FromBody] AdjustmentVoucher voucher) { string url = cfg.GetValue <string>("Hosts:Boot") + "/storesup/voucher/" + voucher.Id; Result <Object> result = HttpUtils.Put(url, voucher, Request, Response);//TODO need the exception message more detail return((bool)result.data); }
protected void btn_Reject_Click(object sender, EventArgs e) { AdjustmentVoucher adjv = adjvdao.findAdjustmentVoucherByadjvId(adjvoucherID); adjvdao.RejectAdjustmentVoucherStatus(adjv, supervisorID); Response.Redirect("./SS_ViewAdjustment.aspx"); }
public JsonResult UpdateReason(int adjdId, string reason, int adjId) { AdjustmentVoucher adj = new AdjustmentVoucher(); if (TempData["AdjustQty"] == null) { adj = AdjustmentVoucherService.Instance.getAdjustmentVoucherById(adjId); } else if (TempData["AdjustQty"] != null) { adj = (AdjustmentVoucher)TempData["AdjustQty"]; TempData.Keep("AdjustQty"); } if (adj.Id == adjId) { if (adj.AdjustmentVoucherDetails.Where(x => x.Id == adjdId).Count() <= 0) { AdjustmentVoucherDetail newadjd = AdjustmentVoucherService.Instance.getAdjustmentVoucherDetailById(adjdId); adj.AdjustmentVoucherDetails.Add(newadjd); } adj.AdjustmentVoucherDetails.Single(x => x.Id == adjdId).Reason = reason; TempData["AdjustQty"] = adj; } return(Json(true, JsonRequestBehavior.AllowGet)); }
public JsonResult CreateVoucher(List <AdjustmentVoucherDetail> newVoucherDetails) { if (newVoucherDetails == null) { return(Json(0)); } else { CustomPrincipal currenUser = (CustomPrincipal)System.Web.HttpContext.Current.User; AdjustmentVoucher newVoucher = new AdjustmentVoucher { AdjustmentDate = DateTime.Now, Status = VoucherStatus.Pending, StoreEmployeeID = currenUser.UserID }; db.AdjustmentVouchers.Add(newVoucher); db.SaveChanges(); int voucherID = newVoucher.AdjustmentVoucherID; newVoucherDetails = CheckDuplicateInVoucher(newVoucherDetails); foreach (AdjustmentVoucherDetail newVoucherDetail in newVoucherDetails) { newVoucherDetail.VoucherID = voucherID; db.AdjustmentVoucherDetails.Add(newVoucherDetail); } int record = db.SaveChanges(); return(Json(voucherID)); } }
/// <summary> /// Sub function to confirm the disbursement transaction when there occur item damaged or missing /// </summary> /// <param name="itemNo"></param> /// <param name="qtyChange"></param> /// <param name="currentBalance"></param> /// <param name="remark"></param> private static void CreateAdjustmentVoucherInCollectionPoint(string itemNo, int qtyChange, int currentBalance, string remark = "") { var adjVoucher = new AdjustmentVoucher() { itemNo = itemNo, quantity = qtyChange, remark = remark, date = DateTime.Now.Date }; DbFactory.Instance.context.AdjustmentVouchers.Add(adjVoucher); DbFactory.Instance.context.SaveChanges(); var sc = new StockCard() { itemNo = itemNo, remark = string.Format("Adjustment Voucher: {0}", adjVoucher.voucherId), quantity = qtyChange, balance = currentBalance, dateModified = DateTime.Now.Date }; DbFactory.Instance.context.StockCards.Add(sc); DbFactory.Instance.context.SaveChanges(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { adjvID = Int32.Parse(Request.QueryString["adjvID"]); managerID = (string)Session["loginID"]; AdjustmentVoucher adjv = adjvdao.findAdjustmentVoucherByadjvId(adjvID); string staffName = adjv.StoreStaff.storeStaffName; string authorisedby = sDAO.getStoreStaffNameByID(adjv.authorisedBy); string status = adjv.status; DateTime adjvDate = adjv.adjDate; if (adjv.status != "PendingForManager") { TextBox_Remarks.Style.Value = " display:none;"; button_Reject.Style.Value = " display:none;"; button_Approve.Style.Value = " display:none;"; } Label_StoreStafID.Text = staffName; lblDate.Text = adjvDate.ToString("dd/MM/yyyy"); lblAdjvID.Text = Convert.ToString(adjvID);; Label_Authorisedby.Text = authorisedby; lblStatus.Text = status; updateGV(); } }
protected void btn_Reject_Click(object sender, EventArgs e) { AdjustmentVoucher adjv = adjvdao.findAdjustmentVoucherByadjvId(adjvID); adjvdao.RejectAdjustmentVoucherStatus(adjv, managerID); Response.Redirect("./SM_ApproveAdjustment.aspx"); }
public static void deleteAdjustmentByVoucherNumber(int vouchernumber) { AdjustmentVoucher adj = findUnapprovedAdjByVoucherNumber(vouchernumber); ds.AdjustmentVouchers.Remove(adj); ds.SaveChanges(); }
public async Task <IActionResult> GetAdjustmentVoucherById(int id) { AdjustmentVoucher adjustment = new AdjustmentVoucher(); int price; using (var httpClient = new HttpClient()) { using (var response = await httpClient.GetAsync(api_url + "/adjustmentId/" + id)) { string apiResponse = await response.Content.ReadAsStringAsync(); adjustment = JsonConvert.DeserializeObject <AdjustmentVoucher>(apiResponse); } using (var response = await httpClient.GetAsync(api_url_itemPrice + "/getPrice/" + adjustment.ItemID)) { string apiResponse = await response.Content.ReadAsStringAsync(); price = JsonConvert.DeserializeObject <int>(apiResponse); } } ViewData["price"] = price; ViewData["adjustmentById"] = adjustment; return(View("AdjustVoucherDetailsClerk")); }
public void AddtoAdjustmentVoucher(ADProjectDb db, int voucherId, AdjustmentDetail AD) { // Update cost of adjustmentDetail double price = (from IC in db.ItemCatalogue join SC in db.SupplierCatalogue on IC.ItemCatalogueId equals SC.ItemId where SC.SupplierRank == 1 where IC.ItemCatalogueId == AD.ItemCatalogueId select SC.ItemPrice).FirstOrDefault(); AD.Cost = AD.Quantity * price; //Add to AdjustmentDetail Database db.AdjustmentDetail.Add(AD); AdjustmentVoucher adjustmentVoucher = db.AdjustmentVoucher.Where(x => x.AdjustmentVoucherId == voucherId).FirstOrDefault(); if (adjustmentVoucher != null) { if (adjustmentVoucher.AdjustmentDetail == null) { adjustmentVoucher.AdjustmentDetail = new List <AdjustmentDetail>(); } adjustmentVoucher.AdjustmentDetail.Add(AD); } db.SaveChanges(); }
public async Task <IActionResult> Main(string itemid, int?id) { MyUser user = _context.MyUser.Where(p => p.Email == HttpContext.User.Identity.Name).ToList().FirstOrDefault(); int userID = user.UserId; AdjustmentVoucher AV; if (id == 0) { AV = new AdjustmentVoucher { UserId = userID, Status = "Pending" }; _context.Add(AV); await _context.SaveChangesAsync(); id = AV.AdjustId; } else { AV = _context.AdjustmentVoucher.Find(id); } AVDetails checkAVD = _context.Avdetails.Where(d => d.AdjustId == AV.AdjustId & d.ItemId == itemid).SingleOrDefault(); AVDetails avd; if (checkAVD == null) { avd = new AVDetails(); avd.AdjustId = AV.AdjustId; avd.ItemId = itemid; _context.Add(avd); await _context.SaveChangesAsync(); } return(Redirect("~/AVDetails/ViewAv/" + id)); }
public void addAdjV(List <AdjustmentVoucherItemcart> list) { AdjustmentVoucher adjvoucher = new AdjustmentVoucher(); adjvoucher.storeStaffID = (string)System.Web.HttpContext.Current.Session["loginID"]; adjvoucher.adjDate = DateTime.Now; adjvoucher.status = "pending"; adjvoucher.authorisedBy = ""; context.AdjustmentVouchers.Add(adjvoucher); int adjvID = adjvoucher.adjVID; /*************Then Add ADJVItems******************/ AdjustmentVoucherItemDAO adjvidao = new AdjustmentVoucherItemDAO(); foreach (AdjustmentVoucherItemcart cartitem in list) { AdjustmentVoucherItem adjvi = new AdjustmentVoucherItem(); adjvi.adjVID = adjvoucher.adjVID; adjvi.itemID = cartitem.ItemID; adjvi.quantity = cartitem.Qty; adjvi.record = cartitem.Record; context.AdjustmentVoucherItems.Add(adjvi); } context.SaveChanges(); }
public ActionResult ViewVoucherDetail(string deleteid, string issubmit) { var db = new ADProjectDb(); AdjustmentVoucher adjustment = (AdjustmentVoucher)Session["newvoucher"]; List <AdjustmentDetail> details = (List <AdjustmentDetail>)Session["details"]; List <string> items = (List <string>)Session["des"]; if (deleteid != null) { for (int i = 0; i < details.Count; i++) { if (details[i].ItemCatalogueId.ToString() == deleteid) { details.Remove(details[i]); items.Remove(items[i]); } } } if (issubmit == "yes") { db.AdjustmentVoucher.Add(adjustment); for (int i = 0; i < details.Count(); i++) { db.AdjustmentDetail.Add(details[i]); } db.SaveChanges(); Session["detail"] = null; Session["newvoucher"] = null; return(RedirectToAction("ViewAllVouchers", "AdjustmentVoucher")); } ViewData["details"] = details; ViewData["itemdes"] = items; return(View()); }
public bool ProcessRejectedDisbursement(Staff staff, int DisbursementID) { UnitOfWork uow = new UnitOfWork(); DisbursementList dl = uow.DisbursementListRepository.Get(filter: x => x.ID == DisbursementID, includeProperties: "ItemTransactions.Item").FirstOrDefault(); if (dl == null) { return(false); } AdjustmentVoucher adjustmentVoucher = new AdjustmentVoucher(dl, uow, staff); if (adjustmentVoucher == null) { return(false); } if (uow.StockCardEntryRepository.ProcessAdjustmentVoucher(adjustmentVoucher)) { uow.AdjustmentVoucherRepository.Insert(adjustmentVoucher); uow.Save(); Debug.WriteLine("Adjustment Voucher inserted successfully into DB for rejected DL"); //Update the respective inventory item foreach (DocumentItem di in adjustmentVoucher.DocumentItems) { if (!UpdateInStoreQty(di.Item.ID)) { Debug.WriteLine("Update In Store Qty failed for" + di.Item.ID); } } return(true); } return(false); }
public AdjustmentVoucher CreateAdjustmentvoucher() { int clerkid = (int)HttpContext.Session.GetInt32("Id"); AdjustmentVoucher av = scservice.CreateAdjustmentVoucher(clerkid); return(av); }
public void AutoAdjustmentsForRetrieval(int clerkEmployeeId, List <RetrievalItemDTO> retrievalList) { AdjustmentVoucher openAV = adjustmentVoucherRepo.FindOneBy(x => x.EmployeeId == clerkEmployeeId && x.Status == "Open"); foreach (var item in retrievalList) { if (item.NeededQuantity > item.RetrievedQty) //retrieval short of needed { if (openAV == null) //no open AV for this clerk { //open new AV openAV = new AdjustmentVoucher { Date = DateTime.Now, EmployeeId = clerkEmployeeId, Status = AdjustmentVoucherStatus.Open.ToString() }; //persist in DB openAV = adjustmentVoucherRepo.Create(openAV); } //create adjustment voucher detail int adjustmentQty = item.RetrievedQty - item.NeededQuantity; AdjustmentVoucherDetail newAVD = new AdjustmentVoucherDetail { AdjustmentVoucherId = openAV.Id, DateTime = DateTime.Now, Quantity = adjustmentQty, Reason = AdjustmentVoucherDefaultReasons.RETRIEVAL_SHORTAGE.ToString(), StationeryId = item.StationeryId }; adjustmentVoucherDetailRepo.Create(newAVD); } } }
public string CreateNewId() { // 029_06_2020 AdjustmentVoucher lastcreatedvoucher = dbcontext.AdjustmentVouchers.OrderByDescending(x => x.InitiatedDate).Take(1).FirstOrDefault(); string lastcreatedid = lastcreatedvoucher.Id; int lastnum = int.Parse(lastcreatedid.Substring(0, 3)); int lastcreatedmonth = int.Parse(lastcreatedid.Substring(4, 2)); int lastcreatedyear = int.Parse(lastcreatedid.Substring(7, 4)); string num = "001"; int initiatedatemonth = int.Parse(DateTime.Now.ToString("MM")); int initiatedateyear = int.Parse(DateTime.Now.ToString("yyyy")); if (lastcreatedmonth == initiatedatemonth && lastcreatedyear == initiatedateyear) { lastnum++; if (lastnum >= 10) { string newid = string.Format("0{0}_{1}_{2}", lastnum, DateTime.Now.ToString("MM"), initiatedateyear); return(newid); } else { string newid = string.Format("00{0}_{1}_{2}", lastnum, DateTime.Now.ToString("MM"), initiatedateyear); return(newid); } } else { string newid = string.Format("{0}_{1}_{2}", num, DateTime.Now.ToString("MM"), initiatedateyear); return(newid); } }
public static void addNewAdjustVoucherWithArrayVoucherDetails(AdjustmentVoucher voucher) { UniversityStoreEntities context = new UniversityStoreEntities(); context.AddToAdjustmentVouchers(voucher); context.SaveChanges(); }
public static void createAdjustmentVoucher(AdjustmentVoucher item) { int items = item.AdjustmentItems.Count; ds.AdjustmentVouchers.Add(item); ds.SaveChanges(); }
public bool UpdateStockCardForApprovedAdjustmentVoucher(AdjustmentVoucher a) { AdjustmentVoucher av = avrepo.FindAdjustmentVoucherById(a.Id); List <AdjustmentVoucherDetail> avd = av.AdjustmentVoucherDetails; DateTime dateTime = DateTime.UtcNow.Date; DateTimeOffset dt = new DateTimeOffset(dateTime, TimeSpan.Zero).ToUniversalTime(); long dateofadj = dt.ToUnixTimeMilliseconds(); foreach (AdjustmentVoucherDetail i in avd) { Transaction t_new = new Transaction(); t_new.ProductId = i.ProductId; t_new.Date = dateofadj; StringBuilder builder = new StringBuilder(); t_new.Description = builder.Append("Approved Adjustment Voucher due to ").Append(i.Reason).ToString(); t_new.Qty = i.QtyAdjusted; Transaction t_old = trepo.GetLatestTransactionByProductId(i.ProductId); t_new.Balance = t_old.Balance + t_new.Qty; if (t_new.Balance <= 0) { t_new.Balance = 0; } t_new.UpdatedByEmpId = av.InitiatedClerkId; t_new.RefCode = "AV ID: " + av.Id.ToString(); trepo.SaveNewTransaction(t_new); } return(true); }
public string UpdateAdjustmentVoucher(string id, string action, string remarks) { AdjustmentVoucher adjustmentVoucher = findAdjustmentVoucher(id); string response = "Adjustment Voucher: [" + adjustmentVoucher.Id + "] request for " + action; if (adjustmentVoucher == null) { response += " has failed to locate"; } if (action == "approve") { bool res = updateInventory(adjustmentVoucher.InventoryId, adjustmentVoucher.qty); switch (res) { case true: response += " is sucessed."; adjustmentVoucher.status = Status.APPROVED; break; case false: response += " is denied as there is stock is less than the amount to be deducted."; break; } } if (action == "reject") { adjustmentVoucher.status = Status.REJECTED; response += " is sucessed."; } adjustmentVoucher.remarks = remarks; dbcontext.Update(adjustmentVoucher); dbcontext.SaveChanges(); return(response); }
/// <summary> /// RejectAdj /// </summary> /// <param name="AdjID">AdjustmentVoucher ID</param> /// <returns>true or false</returns> public bool rejectAdj(string AdjID, string ApprovedBy) { bool result = true; //change status of adj voucher to reject AdjustmentVoucher adjvoucher = (from x in ctx.AdjustmentVoucher where x.AdjID == AdjID select x).First(); adjvoucher.Status = "REJECT"; adjvoucher.ApprovedBy = Convert.ToInt32(ApprovedBy); try { ctx.SaveChanges(); } catch { result = false; } if (result == true) { //send notification: NotificationController nt = new NotificationController(); nt.sendNotification(9, Convert.ToInt32(adjvoucher.ReportedBy), adjvoucher.AdjID); } return(result); }
public bool ProcessStockAdjustmentEntry(Staff staff) { UnitOfWork uow = new UnitOfWork(); if (HttpContext.Current.Session["AdjustmentCart"] == null) { return(false); } AdjustmentVoucherVM Voucher = (AdjustmentVoucherVM)HttpContext.Current.Session["AdjustmentCart"]; AdjustmentVoucher adjustmentVoucher = new AdjustmentVoucher(Voucher, uow, staff); if (uow.StockCardEntryRepository.ProcessAdjustmentVoucher(adjustmentVoucher)) { uow.AdjustmentVoucherRepository.Insert(adjustmentVoucher); uow.Save(); Debug.WriteLine("Adjustment Voucher inserted successfully into DB"); //Update the respective inventory item foreach (AdjustmentItemVM adjustment in Voucher.AdjustmentItems) { if (!UpdateInStoreQty(adjustment.ItemID)) { Debug.WriteLine("Update In Store Qty failed for" + adjustment.ItemID); } } return(true); } return(false); }
//Method1 public void SendtoManager(AdjustmentVoucher adjv, string managerID) { StoreStaffDAO stsdao = new StoreStaffDAO(); StoreStaff sts = stsdao.getstorestaffbyrole("manager"); adjv.authorisedBy = sts.role;//manager only one person context.SaveChanges(); }
public static void approveAdjVoucher(int vouchernumber, int userNo) { AdjustmentVoucher adj = findUnapprovedAdjByVoucherNumber(vouchernumber); adj.approvercode = userNo; adj.approvaldate = DateTime.Today; ds.SaveChanges(); }
public void adjustItem(AdjustmentVoucher adjust) { //sce.AdjustmentItems.Add(adjust); //sce.SaveChanges(); sce.AdjustmentVouchers.Add(adjust); sce.SaveChanges(); }
public bool createVoucherAdj(AdjustmentVoucher adj) { BusinessLogic.AdjustVoucherController BL = new BusinessLogic.AdjustVoucherController(); if (BL.createVoucherAdj(adj)) { OutgoingWebResponseContext response = WebOperationContext.Current.OutgoingResponse; response.StatusCode = HttpStatusCode.OK; return true; } else { OutgoingWebResponseContext response = WebOperationContext.Current.OutgoingResponse; response.StatusCode = HttpStatusCode.NotFound; return false; } }
/// <summary> /// CreateVoucherAdj /// </summary> /// <param name="adj">AdjustVoucher Object (ReportedBy, Status)</param> /// <returns>True or False</returns> public bool createVoucherAdj(AdjustmentVoucher adj) { bool result = true; //double totAmt = 0.0; string newID = getAdjVoucherId(); adj.AdjID = newID; adj.Date = DateTime.Now; ctx.AdjustmentVoucher.Add(adj); try { ctx.SaveChanges(); } catch { result = false; } return result; }
/// <summary> /// Get new Adjustment Voucher ID /// </summary> /// <returns>New Adj ID</returns> public string getAdjVoucherId() { AdjustmentVoucher adj = new AdjustmentVoucher(); adj = (from a in ctx.AdjustmentVoucher orderby a.AdjID descending select a).FirstOrDefault(); if (adj != null) { string oldID = adj.AdjID; //001/09/2015 string oldno = oldID.Substring(0, 3); //001 string oldmonth = oldID.Substring(4, 2); //09 int oldmonth_Int = Convert.ToInt32(oldmonth);//09 --> 9 string month = DateTime.Now.Month.ToString();//09 string year = DateTime.Now.Year.ToString(); int oldno_Int = Convert.ToInt32(oldno);// 01 --> 1 string d = Convert.ToString(oldno_Int + 1); string newID = ""; if (oldmonth_Int == Convert.ToInt32(month)) // 9 == 9 { if (Convert.ToInt32(oldmonth) < 10) month = "0" + month; d = d.PadLeft(3, '0'); newID = d + "/" + month + "/" + year; } else { if (Convert.ToInt32(month) < 10) month = "0" + month; newID = "001" + "/" + month + "/" + year; } return newID; } else { return "001/09/2015"; } }