public int ManageDuplicateUnpaidPurchaseInvoice() { int rowFocusindex = -1; //ShowAllCount = PSDetailsEntity.Where(e => e.SelectedPSID != 0).Count(); TempList = new ObservableCollection <UnpaidPurchaseInvoiceGridViewModel>(); TempList = UnpaidPurchaseInvoicedetailsEntity; var query = TempList.GroupBy(x => x.ID) .Where(g => g.Count() > 1) .ToList(); if (query.Count > 0 && UnpaidPurchaseInvoicedetailsEntity.Count > 1) { var obj1 = query[0].ElementAt(0); var obj2 = query[0].ElementAt(1); int?qty = 1; qty = query[0].ElementAt(0).CountQty + query[0].ElementAt(1).CountQty; var index1 = TempList.IndexOf(query[0].ElementAt(0)); var index2 = TempList.IndexOf(query[0].ElementAt(1)); OnPropertyChanged("UnpaidPurchaseInvoicedetailsEntity"); TempList = UnpaidPurchaseInvoicedetailsEntity; } else { int count = UnpaidPurchaseInvoicedetailsEntity.Count(x => x.ID == 0); if (count == 0) { var row = new UnpaidPurchaseInvoiceGridViewModel(UnpaidInvoiceList); // row.CountQty = 0; // row.GSTRate = TaxRate; UnpaidPurchaseInvoicedetailsEntity.Add(row); OnPropertyChanged("UnpaidPurchaseInvoicedetailsEntity"); TempList = UnpaidPurchaseInvoicedetailsEntity; rowFocusindex = -1; } else { var emptyRow = TempList.Where(y => y.ID == 0).FirstOrDefault(); rowFocusindex = UnpaidPurchaseInvoicedetailsEntity.IndexOf(emptyRow); } } return(rowFocusindex); }
public void createNewUnpaidPurchaseInvoice() { var row = new UnpaidPurchaseInvoiceGridViewModel(UnpaidInvoiceList); //row.SelectedPSID = 0; if (UnpaidPurchaseInvoicedetailsEntity != null) { if (UnpaidPurchaseInvoicedetailsEntity.Count > 0) { UnpaidPurchaseInvoicedetailsEntity.Clear(); // var row = new CollectAmountDataGridViewModel(); // PQDetailsEntity.Add(row); OnPropertyChanged("UnpaidPurchaseInvoicedetailsEntity"); } } UnpaidPurchaseInvoicedetailsEntity.Add(row); OnPropertyChanged("UnpaidPurchaseInvoicedetailsEntity"); }
public bool CanSave(object param) { string msg = string.Empty; bool status = false; var list1 = UnpaidPurchaseInvoicedetailsEntity.Where(x => x.ID == null).ToList(); var list = UnpaidPurchaseInvoicedetailsEntity.Except(list1); foreach (var item in list) { var date = item.InvoiceDate; var Customer = item.ID; var InvoiceNo = item.InvoiceNo; var UpdatedAmount = item.UnpaidAmount; Regex r = new Regex(""); if (date != null && Customer != null && InvoiceNo != null && UpdatedAmount != null) { Regex number = new Regex("^[0-9]*$"); //Regex r = new Regex("^(((0[1-9]|[12][0-9]|30)[-/]?(0[13-9]|1[012])|31[-/]?(0[13578]|1[02])|(0[1-9]|1[0-9]|2[0-8])[-/]?02)[-/]?[0-9]{4}|29[-/]?02[-/]?([0-9]{2}(([2468][048]|[02468][48])|[13579][26])|([13579][26]|[02468][048]|0[0-9]|1[0-6])00))$"); // Regex r = new Regex("^(((0[1-9]|[12][0-9]|3[01])[-/]?(0[13578]|1[02])[-/]?([0-9]{2}))|((0[1-9]|[12][0-9]|30)[-/]?(0[13456789]|1[012])[-/]?([0-9]{2}))|((0[1-9]|1[0-9]|2[0-8])[-/]?02[-/]?([0-9]{2}))|(29[-/]?02[-/]?((0[48]|[2468][048]|[13579][26])|(00))))$"); // Regex r = new Regex("^((0[1-9])|(1[0-2]))[-/]?((0[1-9])|(1[0-9])|(2[0-9])|(3[0-1]))[-/]?(([1][9][0-9][0-9])|([2][0-9][0-9][0-9]))$"); if (DateFormat == "dd/MM/yy") { r = new Regex("^(((0[1-9]|[12][0-9]|3[01])[-/](0[13578]|1[02])[-/]([0-9]{2}))|((0[1-9]|[12][0-9]|30)[-/](0[13456789]|1[012])[-/]([0-9]{2}))|((0[1-9]|1[0-9]|2[0-8])[-/]02[-/]([0-9]{2}))|(29[-/]02[-/]((0[48]|[2468][048]|[13579][26])|(00))))$"); } if (DateFormat == "MM/dd/yy") { r = new Regex("^((0[1-9])|(1[0-2]))[-/]((0[1-9])|([0-2][1-9])|(3[0-1])|(20)|(10))[-/](([0-9][1-9])|([1-9]0))$"); } if (DateFormat == "yy/MM/dd") { r = new Regex("^((([0-9][1-9])|([1-9]0))[-/]((0[1-9])|(1[0-2]))[-/]((0[1-9])|([0-2][1-9])|(3[0-1])|(20)|(10)))$"); } if (number.IsMatch(InvoiceNo)) { msg = ""; this.DateErrors = msg; var no = number.IsMatch(InvoiceNo); if (Convert.ToInt32(no) > 0) { msg = ""; this.DateErrors = msg; if (r.IsMatch(date)) { msg = ""; this.DateErrors = msg; // status = true; } else { msg = "Only Date Accepted"; this.DateErrors = msg; status = false; break; } } else { msg = "Positive Number Accepted"; this.DateErrors = msg; status = false; break; } } else { msg = "Only Numbers Accepted"; this.DateErrors = msg; status = false; break; } status = true; } else { status = false; } } return(status); }