public ActionResult UpdateOrCreateCustomer(MyCustomer model) { try { Onboard2DbContext db = new Onboard2DbContext(); if (model.Id > 0) { //update Customer cust = db.Customers.FirstOrDefault(x => x.Id == model.Id); if (cust != null) { cust.Id = model.Id; cust.Name = model.Name; cust.Address = model.Address; } db.SaveChanges(); } else { //Insert Customer cust = new Customer(); cust.Name = model.Name; cust.Address = model.Address; db.Customers.Add(cust); db.SaveChanges(); } return(RedirectToAction("GetCustomerList")); } catch (Exception ex) { throw ex; } }
public override string IsValidated() { var b = true; string validationResult = ""; //Installation Address var msc = new MySalesJobMasterListCustomer(BaseValue.JobID); msc.SetInstallTo(); if (msc.CustomerID == 0) { validationResult += "No Installation Company Selected " + System.Environment.NewLine; b = false; } else { var mc = new MyCustomer(msc.CustomerID); if (MyConvert.ConvertToString(mc.Value.ADDR_1).Length < 5) { validationResult += "No Installation Address " + System.Environment.NewLine; b = false; } } //Document Attached var requiredDocuemntTypes = new int[] { 200 }; for (int i = 0; i < requiredDocuemntTypes.Length; i++) { var docTypeID = requiredDocuemntTypes[i]; var docAttached = _db.PermitDocuments.Where(x => x.BaseAppID == BaseValue.BaseAppID & x.DocType == docTypeID).ToList(); if (!docAttached.Any()) { var docType = _db.PermitDocumentTypes.Find(docTypeID); validationResult += "Document Required: " + docType.TypeName + System.Environment.NewLine; b = false; } } //Leadtime if (BaseValue.Deadline <= DateTime.Today) { validationResult += "Lead time is 5 business days " + System.Environment.NewLine; b = false; } else { var endDate = Convert.ToDateTime(BaseValue.Deadline); if (MyDateTime.GetDiffHoursOfWeekday(DateTime.Today, endDate) < 24 * NLeadTime) { validationResult += "Lead time is 5 business days " + System.Environment.NewLine; b = false; } } return(b ? "ok" : validationResult); }
public static async Task <CustomerValidator> CreateAsync(MyCustomer customer) { var validator = new CustomerValidator(customer); // get country validation rules await validator.InitValidationRules(customer.BillingProfile.Address.Country); return(validator); }
static void Main(string[] args) { MyCustomer customer = new MyCustomer(); DateTime now = DateTime.Now; int age = 10; string text = age.ToString(); customer.CreatedOn = now; Console.WriteLine(text); }
// ADD OR EDIT public ActionResult AddOrEdit(int Id) { Onboard2DbContext db = new Onboard2DbContext(); MyCustomer model = new MyCustomer(); if (Id > 0) { Customer cust = db.Customers.SingleOrDefault(x => x.Id == Id); model.Id = cust.Id; model.Name = cust.Name; model.Address = cust.Address; } return(PartialView("AddOrEdit", model)); }
public void ImportAddressFromCustomer() { //Subcontract-->Project-->IsInstallTo->Contact and Customer var subcontract = new MySubContract(Value.SubContractID); var msc = new MySalesJobMasterListCustomer(subcontract.Value.JobID); msc.SetInstallTo(); if (msc.CustomerID < 1000) { Result = "Request Failed, No Install to Customer Selected."; } else { var myCustomer = new MyCustomer(msc.CustomerID); var myContact = new MyCustomerContact(msc.ContactID); string addr = myCustomer.Value.ADDR_1; if (!Convert.IsDBNull(myCustomer.Value.ADDR_2)) { addr = addr + " " + myCustomer.Value.ADDR_2; } Value.Address = addr; Value.City = myCustomer.Value.CITY; Value.Postcode = myCustomer.Value.ZIPCODE; Value.Province = myCustomer.Value.STATE; Value.ShipToName = myCustomer.Value.NAME; string attenName = MyConvert.ConvertToString(myContact.Value.CONTACT_HONORIFIC) + " "; attenName += MyConvert.ConvertToString(myContact.Value.CONTACT_FIRST_NAME) + " "; attenName += MyConvert.ConvertToString(myContact.Value.CONTACT_LAST_NAME); Value.AttnName = attenName.Trim(); Value.AttnPhone = MyConvert.ConvertToString(myContact.Value.CONTACT_PHONE); _db.Entry(Value).State = EntityState.Modified; _db.SaveChanges(); Result = "ok"; } }
/// <summary> /// Create a new Customer which is company information /// </summary> /// <param name="customer"></param> /// <param name="jcID">it is jcID in [Sales_JobMasterList_Customer]</param> private int CreateCustomer(CUSTOMER customer, int jcID) { int rowID = 0; try { var mc = new MyCustomer(); mc.Insert(customer); if (jcID > 0) { mc.UpdateSalesJobMasterListCustomerID(jcID); } rowID = mc.RowID; LogMethods.Log.Debug("CreateCustomer:Debug:" + "Done"); } catch (Exception e) { LogMethods.Log.Error("CreateCustomer:Error:" + e.Message); } return(rowID); }
/// <summary> /// Returns whether or not this order is valid and can be submitted /// </summary> /// /// <remarks> /// Checks: /// - if ProductList size is at least >= 1 /// - if every item in ProductList has a corresponding quantity greater than 0 /// - if MyCustomer is set and valid /// - if MyLocation is set and valid /// </remarks> /// /// <returns> /// Returns true if a valid order, false if not. /// </returns> public bool IsValid() { // Not valid if Customer or Location have not been set to order yet if (MyCustomer == null || MyLocation == null) { throw new ArgumentNullException("Customer or Location is null"); } // Not valid if Location or Customer isn't valid if (!MyLocation.IsValid() || !MyCustomer.IsValid()) { throw new ArgumentException("Customer or Location is invalid"); } // If order's list doesn't have any items in it, order is invalid if (ProductList.Count <= 0) { throw new Exception("Order's list cannot be empty"); } return(true); }
public override string IsValidated() { var b = true; string validationResult = ""; var isCityOfToronto = false; //Leadtime if (BaseValue.Deadline <= DateTime.Today) { validationResult += "Lead time is 5 business days " + System.Environment.NewLine; b = false; } else { var endDate = Convert.ToDateTime(BaseValue.Deadline); if (MyDateTime.GetDiffHoursOfWeekday(DateTime.Today, endDate) < 24 * NLeadTime) { validationResult += "Lead time is 5 business days " + System.Environment.NewLine; b = false; } } if (MyConvert.ConvertToString(Value.OccupationTimeStart).Length < 3) { validationResult += "Occupation Start Time Required" + System.Environment.NewLine; b = false; } if (MyConvert.ConvertToString(Value.OccupationTimeEnd).Length < 3) { validationResult += "Occupation End Time Required" + System.Environment.NewLine; b = false; } // if (Value.TypeOfTruck == 0) { validationResult += "Please Fill out Type of Truck " + System.Environment.NewLine; b = false; } //Installation Address var msc = new MySalesJobMasterListCustomer(BaseValue.JobID); msc.SetInstallTo(); if (msc.CustomerID == 0) { validationResult += "No Installation Company Selected " + System.Environment.NewLine; b = false; } else { var mc = new MyCustomer(msc.CustomerID); var customer = mc.Value; if (MyConvert.ConvertToString(customer.ADDR_1).Length < 5) { validationResult += "No Installation Address " + System.Environment.NewLine; b = false; } if (MyConvert.ConvertToString(customer.CITY).Length < 3) { validationResult += "Landlord City Required " + System.Environment.NewLine; b = false; } else { isCityOfToronto = GetIsCityOfToronto(customer.CITY); } if (MyConvert.ConvertToString(customer.ZIPCODE).Length < 4) { validationResult += "Landlord Postcode Required " + System.Environment.NewLine; b = false; } } if (MyConvert.ConvertToString(Value.ForemanName).Length < 2) { validationResult += "Foreman Name Required" + System.Environment.NewLine; b = false; } if (MyConvert.ConvertToString(Value.ForemanPhone).Length < 9) { validationResult += "Foreman Name Required" + System.Environment.NewLine; b = false; } //301 Insurance 2 30 //302 Additional Insurance for City of Toronto 2 30 //Document Attached int docTypeID = 301; var docAttached = _db.PermitDocuments.Where(x => x.BaseAppID == BaseValue.BaseAppID & x.DocType == docTypeID).ToList(); if (!docAttached.Any( )) { var docType = _db.PermitDocumentTypes.Find(docTypeID); validationResult += "Document Required: " + docType.TypeName + System.Environment.NewLine; b = false; } //302 Additional Insurance for City of Toronto 2 30 if (isCityOfToronto) { docTypeID = 302; docAttached = _db.PermitDocuments.Where(x => x.BaseAppID == BaseValue.BaseAppID & x.DocType == docTypeID).ToList(); if (!docAttached.Any()) { var docType = _db.PermitDocumentTypes.Find(docTypeID); validationResult += "Document Required: " + docType.TypeName + System.Environment.NewLine; b = false; } } return(b ? "ok" : validationResult); }
public void ImportAddressFromCustomer(string importCustomerType) { //Subcontract-->Project-->IsInstallTo->Contact and Customer var workorder = new MyWorkorder(Value.WoID); var msc = new MySalesJobMasterListCustomer(workorder.Value.jobID); if (importCustomerType == "InstallTo") { msc.SetInstallTo(); } if (importCustomerType == "QuoteTo") { msc.SetQuoteTo(); } if (importCustomerType == "BillTo") { msc.SetBillTo(); } var mc = new MyCustomer(msc.CustomerID); _customer = mc.Value; var mcc = new MyCustomerContact(msc.ContactID); _contact = mcc.Value; if (_customer != null) { string addr = _customer.ADDR_1; if (!Convert.IsDBNull(_customer.ADDR_2)) { addr = addr + " " + _customer.ADDR_2; } Value.Address = addr; Value.City = _customer.CITY; Value.Postcode = _customer.ZIPCODE; Value.Province = _customer.STATE; Value.ShipToName = _customer.NAME; string attenName = MyConvert.ConvertToString(_contact.CONTACT_HONORIFIC) + " "; attenName += MyConvert.ConvertToString(_contact.CONTACT_FIRST_NAME) + " "; attenName += MyConvert.ConvertToString(_contact.CONTACT_LAST_NAME); Value.AttnName = attenName.Trim(); Value.AttnPhone = MyConvert.ConvertToString(_contact.CONTACT_PHONE); //For Delivery Note Value.DeliveryDate = DateTime.Today; Value.WorkorderNumber = workorder.Value.WorkorderNumber; var emp = new FsEmployee(Convert.ToInt32(workorder.Value.Sales)); Value.AeName = emp.NickName; Value.AePhone = emp.GetCompanyPhoneExtension(); Value.InvoiceNumber = workorder.GetInvoices(); Value.NoteTypeID = 0; _db.Entry(Value).State = EntityState.Modified; _db.SaveChanges(); Result = "ok"; } else { Result = "Could not find the specified Customer."; } }
public override string IsValidated() { var b = true; string validationResult = ""; //Number of Sign if (MyConvert.ConvertToDouble(Value.NumberOfSigns) == 0) { validationResult += "Number of Signs required." + System.Environment.NewLine; b = false; } //Estimated Value if (MyConvert.ConvertToDouble(Value.ProjectValueEstimated) == 0) { validationResult += "Estimated Project Valued required." + System.Environment.NewLine; b = false; } //Installation Address var msc = new MySalesJobMasterListCustomer(BaseValue.JobID); msc.SetInstallTo(); if (msc.CustomerID == 0) { validationResult += "No Installation Company Selected " + System.Environment.NewLine; b = false; } else { var mc = new MyCustomer(msc.CustomerID); if (MyConvert.ConvertToString(mc.Value.ADDR_1).Length < 5) { validationResult += "No Installation Address " + System.Environment.NewLine; b = false; } } //Landlord if (Value.LandlordID < 1000) { validationResult += "Enter a Landlord Please " + System.Environment.NewLine; b = false; } else { var landlord = _db.PermitLandlords.Find(Value.LandlordID); //Company Name if (MyConvert.ConvertToString(landlord.NAME).Length < 5) { validationResult += "Landlord Name Required" + System.Environment.NewLine; b = false; } //Address if (MyConvert.ConvertToString(landlord.ADDR_1).Length < 5) { validationResult += "Landlord Address Required " + System.Environment.NewLine; b = false; } if (MyConvert.ConvertToString(landlord.CITY).Length < 3) { validationResult += "Landlord City Required " + System.Environment.NewLine; b = false; } if (MyConvert.ConvertToString(landlord.ZIPCODE).Length < 4) { validationResult += "Landlord Postcode Required " + System.Environment.NewLine; b = false; } } //Landlord Contact if (Value.LandlordContactID < 1000) { validationResult += "Enter a Landlord Contact " + System.Environment.NewLine; b = false; } else { var contact = _db.PermitLandlordContacts.Find(Value.LandlordContactID); var l1 = MyConvert.ConvertToString(contact.CONTACT_FIRST_NAME).Length; var l2 = MyConvert.ConvertToString(contact.CONTACT_LAST_NAME).Length; if (l1 + l2 < 2) { validationResult += "Landlord Contact Name Required" + System.Environment.NewLine; b = false; } if (MyConvert.ConvertToString(contact.CONTACT_PHONE).Length < 9) { validationResult += "Landlord Contact Phone Required" + System.Environment.NewLine; b = false; } } //Document Attached var requiredDocuemntTypes = new int[] { 10, 12, 14, 16 }; for (int i = 0; i < requiredDocuemntTypes.Length; i++) { var docTypeID = requiredDocuemntTypes[i]; var docAttached = _db.PermitDocuments.Where(x => x.BaseAppID == BaseValue.BaseAppID & x.DocType == docTypeID).ToList(); if (!docAttached.Any( )) { var docType = _db.PermitDocumentTypes.Find(docTypeID); validationResult += "Document Required: " + docType.TypeName + System.Environment.NewLine; b = false; } } return(b ? "ok" : validationResult); }
private string IsValidated() { var b = true; string validationResult = ""; var msc = new MySalesJobMasterListCustomer(Value.JobID); msc.SetInstallTo(); if (msc.CustomerID < 1000) { validationResult += "No Installation Company Selected " + System.Environment.NewLine; b = false; } else { var myCustomer = new MyCustomer(msc.CustomerID); if (MyConvert.ConvertToString(myCustomer.Value.ADDR_1).Length < 5) { b = false; validationResult += "No Installation Address " + System.Environment.NewLine; } } if (Value.ContactPerson1 == 0) { validationResult += "Contact person required." + System.Environment.NewLine; b = false; } if (MyConvert.IsDate(Value.TargetDate)) { if (Value.TargetDate <= DateTime.Today) { validationResult += "Target Date should not be early than today. " + System.Environment.NewLine; b = false; } } else { validationResult += "Invalid Target Date format. " + System.Environment.NewLine; b = false; } if (!MyString.IsStringLengthLongerThan(3, Value.BudgetProvideBy)) { validationResult += "Budget Provide By Whom Required." + System.Environment.NewLine; b = false; } if (!MyString.IsStringLengthLongerThan(3, Value.Requirement)) { validationResult += "Please Enter Requirement." + System.Environment.NewLine; b = false; } var budgetAmount = 100; if (Value.RequirementID >= 6530) { budgetAmount = 100; //1 } if (Value.Budget < budgetAmount) { validationResult += "Normal Job Budget should >=$100, other Job Budget >=$100 " + System.Environment.NewLine; b = false; } return(b ? "ok" : validationResult); }
public ActionResult New(MyCustomer myCustomer) { _dbContext.MyCustomers.Add(myCustomer); _dbContext.SaveChanges(); return(RedirectToAction("Detail", "MyCustomer", new { id = myCustomer.Id })); }
private CustomerValidator(MyCustomer customer) { Customer = customer; ValidationErrors = new List <string>(); }
private void PrintReciept(Object sender, PrintPageEventArgs e) { Graphics graphics = e.Graphics; Font font = new Font("Courier New", 10); float fontHeight = font.GetHeight(); int startX = 250; int startY = 0; int Offset = 20; int fontwidth = 10; String ItemName, CatName = ""; String ItemSize = ""; String ItemPrice = ""; String ItemQuantity = ""; int stringCollLenth = 0; String Concat = ""; String[] Split = { "", "" }; List <String[]> SplitAddr = new List <string[]>(); PrintDocument Reciept = new PrintDocument(); StringFormat Rformat = new StringFormat(StringFormatFlags.DirectionRightToLeft); graphics.DrawString("Serial: " + NewOrder.Order_GetOrderID(), new Font("Courier New", 8), new SolidBrush(Color.Black), startX - 160, startY + Offset); Offset = Offset + 20; graphics.DrawString("مرحبا بكم في مطعم" + "\n" + " شيخ البلد", new Font("Courier New", 14, FontStyle.Bold), new SolidBrush(Color.Black), startX - 10, startY + Offset, Rformat); Offset = Offset + 50; graphics.DrawString("أبو مهند", new Font("Courier New", 10, FontStyle.Bold), new SolidBrush(Color.Black), startX - 75, startY + Offset, Rformat); Offset = Offset + 60; graphics.DrawString("Order #:" + NewOrder.Order_GetOrderSubID(), new Font("Courier New", fontwidth), new SolidBrush(Color.Black), startX - 240, startY + Offset); Offset = Offset + 20; #if DELIVERY graphics.DrawString("Tel: " + NewOrder.Order_GetCustTel(), new Font("Courier New", fontwidth), new SolidBrush(Color.Black), startX - 240, startY + Offset); Offset = Offset + 20; graphics.DrawString("خدمة توصيل", new Font("Courier New", fontwidth), new SolidBrush(Color.Black), startX + 20, startY + Offset, Rformat); Offset = Offset + 30; graphics.DrawString("اسم العميل : " + MyCustomer.GetName(), new Font("Courier New", fontwidth), new SolidBrush(Color.Black), startX + 20, startY + Offset, Rformat); Offset = Offset + 30; int level = 0; String WholeString = ""; int OffsetAfterAddr = 0; if (MyCustomer.GetAddr().Length > 40) { SplitAddr.Add(SplitString(MyCustomer.GetAddr())); while ((SplitAddr[SplitAddr.Count - 1])[0].Length > 40) { level++; for (int lvlindex = 0; lvlindex < level; lvlindex++) { SplitAddr.Add(SplitString((SplitAddr[lvlindex])[0])); SplitAddr.Add(SplitString((SplitAddr[lvlindex])[1])); } } if (level == 0) { WholeString += "\n" + (SplitAddr[0])[0] + "\n" + (SplitAddr[0])[1]; OffsetAfterAddr += (2 * 10); } else { for (int Strings = (level * 2); Strings > 0; Strings--) { if ((SplitAddr[Strings])[0].Length > 15) { WholeString += "\n" + (SplitAddr[SplitAddr.Count - Strings])[0] + "\n" + (SplitAddr[SplitAddr.Count - Strings])[1]; OffsetAfterAddr += (2 * 10); } else { WholeString += "\n" + (SplitAddr[SplitAddr.Count - Strings])[0] + (SplitAddr[SplitAddr.Count - Strings])[1]; OffsetAfterAddr += 10; } } } graphics.DrawString("العنوان : " + WholeString, new Font("Courier New", 8), new SolidBrush(Color.Black), startX + 20, startY + Offset, Rformat); Offset += OffsetAfterAddr; } else { graphics.DrawString("العنوان : " + MyCustomer.GetAddr(), new Font("Courier New", 8), new SolidBrush(Color.Black), startX + 20, startY + Offset, Rformat); } Offset = Offset + 50; #endif graphics.DrawString("Date/Time " + NewOrder.Order_GetTimeStmp(), new Font("Courier New", 8), new SolidBrush(Color.Black), startX - 240, startY + Offset); Offset = Offset + 40; graphics.DrawString("طلب الكمية سعر", new Font("Courier New", 8), new SolidBrush(Color.Black), startX + 15, startY + Offset, Rformat); Offset = Offset + 10; graphics.DrawString("--------------------------------------", new Font("Courier New", 8), new SolidBrush(Color.Black), startX + 15, startY + Offset, Rformat); Offset = Offset + 10; string SpaceMargin = " "; for (int i = 0; i < this.dataSet2.Tables[0].Rows.Count; i++) { ItemName = this.dataSet2.Tables[0].Rows[i].ItemArray[1].ToString(); ItemPrice = this.dataSet2.Tables[0].Rows[i].ItemArray[3].ToString(); ItemSize = this.dataSet2.Tables[0].Rows[i].ItemArray[2].ToString(); ItemQuantity = this.dataSet2.Tables[0].Rows[i].ItemArray[0].ToString(); CatName = this.dataSet2.Tables[1].Rows[i].ItemArray[1].ToString(); Concat = CatName + " - " + ItemName + " - " + ItemSize; stringCollLenth = Concat.Length; if (Convert.ToDouble(ItemPrice) >= 10) { SpaceMargin = " "; } else if (Convert.ToDouble(ItemPrice) >= 100) { SpaceMargin = " "; } else { SpaceMargin = " "; } if (stringCollLenth > 14) { Split = SplitString(Concat); graphics.DrawString(Split[0], new Font("Courier New", 8), new SolidBrush(Color.Black), startX + 15, startY + Offset, Rformat); graphics.DrawString(ItemPrice + SpaceMargin + "|" + SpaceMargin + ItemQuantity, new Font("Courier New", 8), new SolidBrush(Color.Black), startX - 245, startY + Offset); Offset = Offset + 10; graphics.DrawString(Split[1], new Font("Courier New", 8), new SolidBrush(Color.Black), startX + 15, startY + Offset, Rformat); Offset = Offset + 15; } else { graphics.DrawString(Concat, new Font("Courier New", 8), new SolidBrush(Color.Black), startX + 15, startY + Offset, Rformat); graphics.DrawString(ItemPrice + SpaceMargin + "|" + SpaceMargin + ItemQuantity, new Font("Courier New", 8), new SolidBrush(Color.Black), startX - 245, startY + Offset); Offset = Offset + 15; } } graphics.DrawString("--------------------------------------", new Font("Courier New", 8), new SolidBrush(Color.Black), startX + 15, startY + Offset, Rformat); Offset = Offset + 15; #if DELIVERY graphics.DrawString("خدمة التوصيل", new Font("Courier New", fontwidth), new SolidBrush(Color.Black), startX + 15, startY + Offset, Rformat); graphics.DrawString(NewOrder.Order_GetDeliveryCharge().ToString(), new Font("Courier New", fontwidth), new SolidBrush(Color.Black), startX - 245, startY + Offset); Offset = Offset + 15; #endif graphics.DrawString("--------------------------------------", new Font("Courier New", 8), new SolidBrush(Color.Black), startX + 15, startY + Offset, Rformat); Offset = Offset + 15; graphics.DrawString("الإجمالي", new Font("Courier New", fontwidth, FontStyle.Bold), new SolidBrush(Color.Black), startX + 15, startY + Offset, Rformat); graphics.DrawString(NewOrder.Order_GetOrderTotal().ToString(), new Font("Courier New", fontwidth, FontStyle.Bold), new SolidBrush(Color.Black), startX - 245, startY + Offset); Offset = Offset + 40; graphics.DrawString("شكرا لزيارتكم مطعم" + "\n" + " شيخ البلد", new Font("Courier New", 10, FontStyle.Bold), new SolidBrush(Color.Black), startX - 40, startY + Offset, Rformat); Offset = Offset + 45; graphics.DrawString("خدمة التوصيل", new Font("Courier New", 10), new SolidBrush(Color.Black), startX - 60, startY + Offset, Rformat); Offset = Offset + 30; graphics.DrawString("16748", new Font("Courier New", 20, FontStyle.Bold), new SolidBrush(Color.Black), startX - 155, startY + Offset); }