public PartyMaster CreatepartyMaster(PartyMaster _objCreate) { try { if (_objCreate != null) { //Check Duplicate using (LocalEntity _context = new LocalEntity()) { var party = _context.tblPartyMasters.OrderByDescending(x => x.PartyId).FirstOrDefault(); int intMaxId = 1; if (party != null) { intMaxId = party.PartyId + 1; } string strPartyCode = "Party00" + intMaxId; _context.tblPartyMasters.Add(new tblPartyMaster { PartyId = intMaxId, PartyCode = strPartyCode, ContactPerson = _objCreate.ContactPerson, Address = _objCreate.Address, Phone = _objCreate.Phone, Mobile = _objCreate.Mobile, Fax = _objCreate.Fax, Email = _objCreate.Email, Pager = _objCreate.Pager, PartyName = _objCreate.PartyName, IsActive = _objCreate.IsActive, CreatedBy = "System", CreatedOn = DateTime.Now }); if (_context.SaveChanges() == 1) { _objCreate.Code = Models.MessageCode.Success; _objCreate.MessageText = _objCreate.PartyName + " has been created successfully."; } else { _objCreate.Code = Models.MessageCode.Error; _objCreate.MessageText = "Not Created. Pleases contact administor !!"; } } } } catch (DbEntityValidationException ex) { throw ex; } catch (Exception ex) { throw ex; } return(_objCreate); }
public Customers CreateCust(Customers _objcust) { try { if (_objcust != null) { //Check Duplicate using (LocalEntity _context = new LocalEntity()) { var cust = _context.tblCustomers.OrderByDescending(x => x.Id).FirstOrDefault(); int intMaxId = 1; if (cust != null) { intMaxId = cust.Id + 1; } string strCustCode = "Cust00" + intMaxId; _context.tblCustomers.Add(new tblCustomer() { Id = intMaxId, Address = _objcust.Address, ContactPerson = _objcust.ContactPerson, Country = _objcust.Country, CreatedBy = _objcust.CreatedBy, CreatedOn = _objcust.CreatedOn, CustomerCode = strCustCode, CustomerName = _objcust.CustomerName, IsActive = true, MobileNo = _objcust.MobileNo }); if (_context.SaveChanges() == 1) { _objcust.Code = Models.MessageCode.Success; _objcust.MessageText = _objcust.CustomerName + " has been created successfully."; } else { _objcust.Code = Models.MessageCode.Error; _objcust.MessageText = "Not Created. Pleases contact administor !!"; } } } } catch (DbEntityValidationException ex) { throw ex; } catch (Exception ex) { throw ex; } return(_objcust); }
public Article CreateArticleMaster(Article _objCreate) { try { if (_objCreate != null) { //Check Duplicate using (LocalEntity _context = new LocalEntity()) { var Art = _context.tblArticles.OrderByDescending(x => x.ArtId).FirstOrDefault(); int intMaxId = 1; if (Art != null) { intMaxId = Art.ArtId + 1; } // string strArtCode = "Art00" + intMaxId; _context.tblArticles.Add(new tblArticle { ArtId = intMaxId, Desc = _objCreate.Desc, ArtNo = _objCreate.ArtNo, Rate = _objCreate.Rate, Unit = _objCreate.Unit, WorkOrderDesc = _objCreate.WorkOrderDesc, IsActive = _objCreate.IsActive, CreatedBy = "System", CreatedOn = DateTime.Now }); if (_context.SaveChanges() == 1) { _objCreate.Code = Models.MessageCode.Success; _objCreate.MessageText = _objCreate.ArtNo + " has been created successfully."; } else { _objCreate.Code = Models.MessageCode.Error; _objCreate.MessageText = "Not Created. Pleases contact administor !!"; } } } } catch (DbEntityValidationException ex) { throw ex; } catch (Exception ex) { throw ex; } return(_objCreate); }
public RefillInk UpdateRefillInk(RefillInk _objUpdate) { RefillInk _objResult = new RefillInk(); try { if (_objUpdate != null) { using (LocalEntity localEntity = new LocalEntity()) { var isExist = (from x in localEntity.tblRefillInks where x.RefillInkColor.ToLower() == _objUpdate.RefillInkColor.ToLower() && x.id != _objUpdate.id select x); if (isExist != null && isExist.Count() > 0) { _objResult.MessageText = "Refill Ink " + _objUpdate.RefillInkColor + "is already exist !!"; } else { var result = localEntity.tblRefillInks.Find(_objUpdate.id); if (result != null) { result.RefillInkColor = result.RefillInkColor == _objUpdate.RefillInkColor ? result.RefillInkColor : _objUpdate.RefillInkColor; result.IsActive = _objUpdate.IsActive; result.ModifiedBy = _objUpdate.ModifiedBy; result.ModifiedOn = _objUpdate.ModifiedOn; } if (localEntity.SaveChanges() == 1) { _objResult.Code = Models.MessageCode.Success; _objResult.MessageText = "Refill Ink " + _objUpdate.RefillInkColor + " has been updated successfully."; } else { _objResult.Code = Models.MessageCode.Failed; _objResult.MessageText = "Not Updated. Please contact System Admin."; } } } } else { _objResult.MessageText = "Please modified refillink to update !"; } } catch (Exception ex) { throw ex; } return(_objResult); }
public RefillInk AddRefillInk(RefillInk _objCreate) { RefillInk _objResult = new RefillInk(); try { if (_objCreate != null) { using (LocalEntity localEntity = new LocalEntity()) { var isExist = (from x in localEntity.tblRefillInks where x.RefillInkColor.ToLower() == _objCreate.RefillInkColor.ToLower() select x); if (isExist != null && isExist.Count() > 0) { _objResult.MessageText = "Refill Ink " + _objCreate.RefillInkColor + "is already exist !!"; } else { localEntity.tblRefillInks.Add(new tblRefillInk { RefillInkColor = _objCreate.RefillInkColor, CreatedBy = _objCreate.CreatedBy, CreatedOn = _objCreate.CreatedOn, IsActive = _objCreate.IsActive }); if (localEntity.SaveChanges() == 1) { _objResult.Code = Models.MessageCode.Success; _objResult.MessageText = "Refill Ink " + _objCreate.RefillInkColor + " has been created successfully."; } else { _objResult.Code = Models.MessageCode.Failed; _objResult.MessageText = "Not Created. Please contact System Admin."; } } } } else { _objResult.MessageText = "Please add refillink to create !"; } } catch (Exception ex) { throw ex; } return(_objResult); }
public Customers UpdateCustomer(Customers _objcust) { try { if (_objcust != null & _objcust.Id > 0) { using (LocalEntity _context = new LocalEntity()) { var obj = _context.tblCustomers.Find(_objcust.Id); if (obj != null) { if (!string.IsNullOrWhiteSpace(_objcust.CustomerName) && _objcust.CustomerName != obj.CustomerName) { obj.CustomerName = _objcust.CustomerName; } if (!string.IsNullOrWhiteSpace(_objcust.Address) && _objcust.Address != obj.Address) { obj.Address = _objcust.Address; } if (!string.IsNullOrWhiteSpace(_objcust.ContactPerson) && _objcust.ContactPerson != obj.ContactPerson) { obj.ContactPerson = _objcust.ContactPerson; } if (!string.IsNullOrWhiteSpace(_objcust.Country) && _objcust.Country != obj.Country) { obj.Country = _objcust.Country; } if (!string.IsNullOrWhiteSpace(_objcust.MobileNo) && _objcust.MobileNo != obj.MobileNo) { obj.MobileNo = _objcust.MobileNo; } //if (!string.IsNullOrWhiteSpace(_objcust.) && _objcust.CustomerName != obj.CustomerName) // obj.CustomerName = _objcust.CustomerName; //if (!string.IsNullOrWhiteSpace(_objcust.CustomerName) && _objcust.CustomerName != obj.CustomerName) // obj.CustomerName = _objcust.CustomerName; //if (!string.IsNullOrWhiteSpace(_objcust.CustomerName) && _objcust.CustomerName != obj.CustomerName) // obj.CustomerName = _objcust.CustomerName; if (_context.SaveChanges() == 1) { _objcust.Code = Models.MessageCode.Success; _objcust.MessageText = _objcust.CustomerName + " has been updated successfully."; } else { _objcust.Code = Models.MessageCode.Error; _objcust.MessageText = "Not Updated. Pleases contact administor !!"; } return(_objcust); } } } } catch (Exception) { throw; } return(_objcust); }
public Article UpdateArticleMaster(Article _objUpdate) { try { if (_objUpdate != null & _objUpdate.ArtId > 0) { using (LocalEntity _context = new LocalEntity()) { var obj = _context.tblArticles.Find(_objUpdate.ArtId); if (obj != null) { if (!string.IsNullOrWhiteSpace(_objUpdate.ArtNo) && _objUpdate.ArtNo != obj.ArtNo) { obj.ArtNo = _objUpdate.ArtNo; } if (!string.IsNullOrWhiteSpace(_objUpdate.Desc) && _objUpdate.Desc != obj.Desc) { obj.Desc = _objUpdate.Desc; } if (!string.IsNullOrWhiteSpace(_objUpdate.WorkOrderDesc) && _objUpdate.WorkOrderDesc != obj.WorkOrderDesc) { obj.WorkOrderDesc = _objUpdate.WorkOrderDesc; } if (!string.IsNullOrWhiteSpace(_objUpdate.Unit) && _objUpdate.Unit != obj.Unit) { obj.Unit = _objUpdate.Unit; } // if (_objUpdate.Rate > 0 && _objUpdate.Email != obj.Email) obj.Rate = _objUpdate.Rate; if (!string.IsNullOrWhiteSpace(_objUpdate.ArtNo) && _objUpdate.ArtNo != obj.ArtNo) { obj.ArtNo = _objUpdate.ArtNo; } obj.IsActive = _objUpdate.IsActive; if (_context.SaveChanges() == 1) { _objUpdate.Code = Models.MessageCode.Success; _objUpdate.MessageText = _objUpdate.ArtNo + " has been updated successfully."; } else { _objUpdate.Code = Models.MessageCode.Error; _objUpdate.MessageText = "Not Updated. Pleases contact administor !!"; } return(_objUpdate); } } } } catch (Exception) { throw; } return(_objUpdate); }
public PartyMaster UpdatePartyMaster(PartyMaster _objUpdate) { try { if (_objUpdate != null & _objUpdate.PartyId > 0) { using (LocalEntity _context = new LocalEntity()) { var obj = _context.tblPartyMasters.Find(_objUpdate.PartyId); if (obj != null) { if (!string.IsNullOrWhiteSpace(_objUpdate.PartyName) && _objUpdate.PartyName != obj.PartyName) { obj.PartyName = _objUpdate.PartyName; } if (!string.IsNullOrWhiteSpace(_objUpdate.Address) && _objUpdate.Address != obj.Address) { obj.Address = _objUpdate.Address; } if (!string.IsNullOrWhiteSpace(_objUpdate.ContactPerson) && _objUpdate.ContactPerson != obj.ContactPerson) { obj.ContactPerson = _objUpdate.ContactPerson; } if (!string.IsNullOrWhiteSpace(_objUpdate.Email) && _objUpdate.Email != obj.Email) { obj.Email = _objUpdate.Email; } if (!string.IsNullOrWhiteSpace(_objUpdate.Fax) && _objUpdate.Fax != obj.Fax) { obj.Fax = _objUpdate.Fax; } if (!string.IsNullOrWhiteSpace(_objUpdate.Mobile) && _objUpdate.Mobile != obj.Mobile) { obj.Mobile = _objUpdate.Mobile; } if (!string.IsNullOrWhiteSpace(_objUpdate.Pager) && _objUpdate.Pager != obj.Pager) { obj.Pager = _objUpdate.Pager; } if (!string.IsNullOrWhiteSpace(_objUpdate.Phone) && _objUpdate.Phone != obj.Phone) { obj.Phone = _objUpdate.Phone; } obj.IsActive = _objUpdate.IsActive; if (_context.SaveChanges() == 1) { _objUpdate.Code = Models.MessageCode.Success; _objUpdate.MessageText = _objUpdate.PartyName + " has been updated successfully."; } else { _objUpdate.Code = Models.MessageCode.Error; _objUpdate.MessageText = "Not Updated. Pleases contact administor !!"; } return(_objUpdate); } } } } catch (Exception) { throw; } return(_objUpdate); }
public Invoice UpdateInvoice(Invoice _objUpdateInvoice) { try { if (_objUpdateInvoice != null) { using (LocalEntity _context = new LocalEntity()) { var _Invoice = (from x in _context.tblInvoices where x.InvoiceNo == _objUpdateInvoice.InvoiceNo select x).FirstOrDefault(); if (_Invoice != null) { _Invoice.PartyNo = string.IsNullOrWhiteSpace(_objUpdateInvoice.PartyNo) ? _Invoice.PartyNo : Convert.ToString(_objUpdateInvoice.PartyNo); _Invoice.BankId = string.IsNullOrWhiteSpace(_objUpdateInvoice.BankId) ? _Invoice.BankId : Convert.ToString(_objUpdateInvoice.BankId); _Invoice.Unit = string.IsNullOrWhiteSpace(_objUpdateInvoice.Unit) ? _Invoice.Unit : Convert.ToString(_objUpdateInvoice.Unit); _Invoice.InvoiceDate = string.IsNullOrWhiteSpace(Convert.ToString(_objUpdateInvoice.InvoiceDate)) ? _Invoice.InvoiceDate : Convert.ToDateTime(_objUpdateInvoice.InvoiceDate); _Invoice.InvoiceCurrency = string.IsNullOrWhiteSpace(_objUpdateInvoice.InvoiceCurrency) ? _Invoice.InvoiceCurrency : Convert.ToString(_objUpdateInvoice.InvoiceCurrency); _Invoice.InvoiceGrandQty = Convert.ToDecimal(_objUpdateInvoice.InvoiceGrandQty); _Invoice.InvoiceGrandAmt = Convert.ToDecimal(_objUpdateInvoice.InvoiceGrandAmt); _Invoice.Remark = string.IsNullOrWhiteSpace(_objUpdateInvoice.Remark) ? _Invoice.Remark : Convert.ToString(_objUpdateInvoice.Remark); _Invoice.DeliveryTerms = string.IsNullOrWhiteSpace(_objUpdateInvoice.DeliveryTerms) ? _Invoice.DeliveryTerms : Convert.ToString(_objUpdateInvoice.DeliveryTerms); _Invoice.DeliveryType = string.IsNullOrWhiteSpace(_objUpdateInvoice.DeliveryType) ? _Invoice.DeliveryType : Convert.ToString(_objUpdateInvoice.DeliveryType); _Invoice.Port = string.IsNullOrWhiteSpace(_objUpdateInvoice.Port) ? _Invoice.Port : Convert.ToString(_objUpdateInvoice.Port); _Invoice.PaymentTerms = string.IsNullOrWhiteSpace(_objUpdateInvoice.PaymentTerms) ? _Invoice.PaymentTerms : Convert.ToString(_objUpdateInvoice.PaymentTerms); _Invoice.DeliveryPeriod = string.IsNullOrWhiteSpace(_objUpdateInvoice.DeliveryPeriod) ? _Invoice.DeliveryPeriod : Convert.ToString(_objUpdateInvoice.DeliveryPeriod); _Invoice.WODelivery = string.IsNullOrWhiteSpace(_objUpdateInvoice.WODelivery) ? _Invoice.WODelivery : Convert.ToString(_objUpdateInvoice.WODelivery); _Invoice.Remarks = string.IsNullOrWhiteSpace(_objUpdateInvoice.Remarks) ? _Invoice.Remarks : Convert.ToString(_objUpdateInvoice.Remarks); _Invoice.WORemarks = string.IsNullOrWhiteSpace(_objUpdateInvoice.WORemarks) ? _Invoice.WORemarks : Convert.ToString(_objUpdateInvoice.WORemarks); _Invoice.Note = string.IsNullOrWhiteSpace(_objUpdateInvoice.Note) ? _Invoice.Note : Convert.ToString(_objUpdateInvoice.Note); _Invoice.PartialShip = string.IsNullOrWhiteSpace(_objUpdateInvoice.PartialShip) ? _Invoice.PartialShip : Convert.ToString(_objUpdateInvoice.PartialShip); _Invoice.TransShipment = string.IsNullOrWhiteSpace(_objUpdateInvoice.TransShipment) ? _Invoice.TransShipment : Convert.ToString(_objUpdateInvoice.TransShipment); //_Invoice.EditedBy = string.IsNullOrWhiteSpace(_objUpdateInvoice.PartyNo) ? _Invoice.PartyNo : Convert.ToString(_objUpdateInvoice.PartyNo); // _Invoice.EditedOn = string.IsNullOrWhiteSpace(_objUpdateInvoice.PartyNo) ? _Invoice.PartyNo : Convert.ToString(_objUpdateInvoice.PartyNo); _Invoice.IsActive = string.IsNullOrWhiteSpace(_objUpdateInvoice.PartyNo) ? _Invoice.IsActive : Convert.ToBoolean(_objUpdateInvoice.IsActive); if (_context.SaveChanges() >= 0) { if (_objUpdateInvoice._objOrderItem.Count() > 0) { //Remove all item from the item details table before update new items in order var removedlist = _context.tbl_InvoiceItemDetails.Where(x => x.InvoiceNo == _objUpdateInvoice.InvoiceNo).ToList(); foreach (var item in removedlist) { _context.tbl_InvoiceItemDetails.Remove(item); } _context.SaveChanges(); //Now adding new row in tables Int32 intInvoiceItemID = GetItemDetailsMax(); List <InvoiceItemDetails> _lstItems = new List <InvoiceItemDetails>(); int itemCount = 0; foreach (var item in _objUpdateInvoice._objOrderItem) { int intlocalInvoiceItemID = intInvoiceItemID + itemCount; _context.tbl_InvoiceItemDetails.Add(new tbl_InvoiceItemDetails { InvoiceItemID = intlocalInvoiceItemID, InvoiceNo = _objUpdateInvoice.InvoiceNo, Amount = item.Amount, ArtDesc = item.ArtDesc, ArtNo = item.ArtNo, Quantity = item.Quantity, Rate = item.Rate, RefileInk = item.RefileInk, WorkOrderDesc = item.WorkOrderDesc }); itemCount++; } _context.SaveChanges(); _objUpdateInvoice.Code = Models.MessageCode.Success; _objUpdateInvoice.MessageText = _objUpdateInvoice.InvoiceNo + " has been update successfully."; _objUpdateInvoice.InvoiceNo = _objUpdateInvoice.InvoiceNo; } } } } } } catch (Exception) { throw; } return(_objUpdateInvoice); }
public Invoice CreateInvoice(Invoice _objCreateInvoice) { try { if (_objCreateInvoice != null) { //Check Duplicate using (LocalEntity _context = new LocalEntity()) { var invoice = _context.tblInvoices.OrderByDescending(x => x.InvoiceId).FirstOrDefault(); int intMaxId = 1; int intInvoiceId = 1; if (invoice != null) { intMaxId = invoice.InvoiceId + 1; intInvoiceId = intInvoiceId + 1; } string strInvoiceNo = "SSB-" + intMaxId; Thread.CurrentThread.CurrentCulture = new CultureInfo("en-IN"); _context.tblInvoices.Add(new tblInvoice { InvoiceId = intInvoiceId, InvoiceNo = strInvoiceNo, PartyNo = _objCreateInvoice.PartyNo, BankId = _objCreateInvoice.BankId, Unit = _objCreateInvoice.Unit, InvoiceDate = _objCreateInvoice.InvoiceDate, InvoiceCurrency = string.Format(_objCreateInvoice.InvoiceCurrency, CultureInfo.InvariantCulture), InvoiceGrandQty = Convert.ToDecimal(_objCreateInvoice.InvoiceGrandQty), InvoiceGrandAmt = _objCreateInvoice.InvoiceGrandAmt, Remark = _objCreateInvoice.Remark, DeliveryTerms = _objCreateInvoice.DeliveryTerms, DeliveryType = _objCreateInvoice.DeliveryType, Port = _objCreateInvoice.Port, PaymentTerms = _objCreateInvoice.PaymentTerms, DeliveryPeriod = _objCreateInvoice.DeliveryPeriod, WODelivery = _objCreateInvoice.WODelivery, Remarks = _objCreateInvoice.Remarks, WORemarks = _objCreateInvoice.WORemarks, Note = _objCreateInvoice.Note, PartialShip = _objCreateInvoice.PartialShip, TransShipment = _objCreateInvoice.TransShipment, CreatedBy = _objCreateInvoice.CreatedBy, CreatedOn = _objCreateInvoice.CreatedOn, EditedBy = _objCreateInvoice.EditedBy, EditedOn = _objCreateInvoice.EditedOn, IsActive = _objCreateInvoice.IsActive, }); if (_context.SaveChanges() == 1) { //Create Item details //var InvoiceItem = _context.tbl_InvoiceItemDetails.OrderByDescending(x => x.InvoiceItemID).FirstOrDefault(); //int intInvoiceItemID = 1; //if (InvoiceItem != null) Int32 intInvoiceItemID = GetItemDetailsMax(); //if (InvoiceItem != null) //{ List <InvoiceItemDetails> _lstItems = new List <InvoiceItemDetails>(); int itemCount = 0; foreach (var item in _objCreateInvoice._objOrderItem) { int intlocalInvoiceItemID = intInvoiceItemID + itemCount; _context.tbl_InvoiceItemDetails.Add(new tbl_InvoiceItemDetails { InvoiceItemID = intlocalInvoiceItemID, InvoiceNo = strInvoiceNo, Amount = item.Amount, ArtDesc = item.ArtDesc, ArtNo = item.ArtNo, Quantity = item.Quantity, Rate = item.Rate, RefileInk = item.RefileInk, WorkOrderDesc = item.WorkOrderDesc }); itemCount++; } //} _context.SaveChanges(); _objCreateInvoice.Code = Models.MessageCode.Success; _objCreateInvoice.MessageText = strInvoiceNo + " has been created successfully."; _objCreateInvoice.InvoiceNo = strInvoiceNo; } else { _objCreateInvoice.Code = Models.MessageCode.Error; _objCreateInvoice.MessageText = "Not Created. Pleases contact administor !!"; } } } } catch (DbEntityValidationException ex) { throw ex; } catch (Exception ex) { throw ex; } return(_objCreateInvoice); }