public override void Save() { if (!Security.Validating.validateFields(this)) { try { string id = "MBR" + Security.Security.generateIdNumber(); string dni = txtDLN.Text.Trim(); string name = txtName.Text.Trim(); string lastname = txtLastname.Text.Trim(); string phone = txtPhone.Text.Trim(); string email = txtEmail.Text.Trim(); string address = (txtApt.Text != "") ? txtStreet.Text.Trim() + ", Apt# " + txtApt.Text.Trim() + ", " + txtCity.Text.Trim() + ", " + cmbState.Text.Trim() + ", " + txtZipcode.Text.Trim() : txtStreet.Text.Trim() + ", " + txtCity.Text.Trim() + ", " + cmbState.Text.Trim() + ", " + txtZipcode.Text.Trim(); var newCustomer = new CustomerModel(id, name, lastname, phone, address, email, dni); Customer_Data.newCustomer(newCustomer); MessageBox.Show("New Customer added", "Success", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); this.Close(); } catch (Exception) { MessageBox.Show("There were an error trying to add this user", "", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
// GET: Customer_Data/Details/5 public ActionResult Details(int?id) { List <int> dataList = new List <int>(); foreach (var item in db.Customer_Data) { var listCustomer = from trans in db.Transaction_Data where trans.ID_Customer == item.ID_Customer select trans.ID_Transaction; int dataCusList = listCustomer.Count(); dataList.Add(dataCusList); } ViewBag.DataCount = dataList.Count; ViewBag.DataListCustomer = dataList; ViewBag.ID = id; var getData = db.Transaction_Data.Where(s => s.ID_Customer == id); ViewBag.getData = getData; if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Customer_Data customer_Data = db.Customer_Data.Find(id); if (customer_Data == null) { return(HttpNotFound()); } return(View(customer_Data)); }
public override global::System.Data.DataSet Clone() { Customer_Data cln = ((Customer_Data)(base.Clone())); cln.InitVars(); cln.SchemaSerializationMode = this.SchemaSerializationMode; return(cln); }
public ActionResult DeleteConfirmed(int id) { Customer_Data customer_Data = db.Customer_Data.Find(id); db.Customer_Data.Remove(customer_Data); db.SaveChanges(); return(RedirectToAction("Index")); }
public IActionResult Post([FromBody] Customer_Data customer) { context = HttpContext.RequestServices.GetService(typeof(DBconnect)) as DBconnect; if (context.Insert(customer) == null) { return(BadRequest()); } return(Ok()); }
public IActionResult Put(int id, [FromBody] Customer_Data customer) { context = HttpContext.RequestServices.GetService(typeof(DBconnect)) as DBconnect; if (context.Update(id, customer) == null) { return(BadRequest()); } return(Ok()); }
public ActionResult Edit([Bind(Include = "ID_Customer,Customer_Name,Phone_Customer,Address_Customer")] Customer_Data customer_Data) { if (ModelState.IsValid) { db.Entry(customer_Data).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(customer_Data)); }
public ActionResult Create([Bind(Include = "ID_Customer,Customer_Name,Phone_Customer,Address_Customer")] Customer_Data customer_Data) { if (ModelState.IsValid) { db.Customer_Data.Add(customer_Data); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(customer_Data)); }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) { Customer_Data ds = new Customer_Data(); global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny(); any.Namespace = ds.Namespace; sequence.Items.Add(any); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte()));) { ; } if ((s1.Position == s1.Length)) { return(type); } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return(type); }
// GET: Customer_Data/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Customer_Data customer_Data = db.Customer_Data.Find(id); if (customer_Data == null) { return(HttpNotFound()); } return(View(customer_Data)); }
private void btnSearch_Click(object sender, EventArgs e) { try { var customer = Customer_Data.getCustomer(txtCustomerId.Text); _cusotmer = customer; txtCustomerName.Text = customer.name + " " + customer.lastname; btnFind.Enabled = true; btnItems.Enabled = true; btnSearch.Enabled = false; } catch (Exception) { MessageBox.Show("There was a problem looking for the customer, try with Customer action.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public Customer_Data Update(int id, Customer_Data customer) { try { using (MySqlConnection conn = new MySqlConnection(ConnectionString)) { String sql = "UPDATE STUDENT SET grade = @grade, cclass = @cclass, name = @name, score = @score WHERE no = @no;"; conn.Open(); conn.Execute(sql, new { grade = Convert.ToInt32(customer.grade), cclass = Convert.ToInt32(customer.cclass), customer.name, customer.score, no = Convert.ToInt32(id) }); conn.Close(); } }catch (Exception ex) { return(null); } return(customer); }
private void UpdateCustomerEventHandler(object sender) { try { txtCustomerId.Text = sender.ToString(); var customer = Customer_Data.getCustomer(sender.ToString()); _cusotmer = customer; txtCustomerName.Text = customer.name + " " + customer.lastname; btnFind.Enabled = true; btnItems.Enabled = true; btnSearch.Enabled = false; } catch (Exception) { MessageBox.Show("There was a problem looking for the customer, try with Customer action.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public Customer_Data Insert(Customer_Data customer) { try { using (MySqlConnection conn = new MySqlConnection(ConnectionString)) { String sql = "INSERT INTO STUDENT VALUE (@grade,@cclass,@no,@name,@score);"; conn.Open(); conn.Execute(sql, new { grade = Convert.ToInt32(customer.grade), cclass = Convert.ToInt32(customer.cclass), no = Convert.ToInt32(customer.no), customer.name, customer.score }); conn.Close(); } } catch (Exception ex) { return(null); } return(customer); }
[TestMethod()] //if the user inputs that 100kWh's were used, the method should charge them just the admin cost of 12 dollars plus the cost of the usage(.07*100) public void CalculateCharge_WithOneHundredKwH_UpdatesBillAmount() { //Arrange decimal kWhUsed = 100; decimal expected = 19m; Customer_Data account; account = new Customer_Data("Tamika", "Taylor", kWhUsed); //Act account.CalculateCharge(); //Assert decimal actual = account.BillAmount; Assert.AreEqual(expected, actual); }
public List <Customer_Data> parseCSV(string path) { List <Customer_Data> parsedData = new List <Customer_Data>(); string[] fields; TextFieldParser parser = null; string line = parser.ReadLine(); try { /*TextFieldParser*/ parser = new TextFieldParser(@"c:\temp\test.csv"); parser.TextFieldType = FieldType.Delimited; parser.SetDelimiters(","); while (!parser.EndOfData) { fields = parser.ReadFields(); // assume the CSV is always with 11 columns if (fields.length == 11) { Customer_Data newData = new Customer_Data(); newData.name = fields[0]; newData.company = fields[1]; // assign to the rest of the customer data properties with each fields parsedData.Add(newData); } else { // error handling of not well formed CSV } } parser.Close(); } catch (Exception e) { MessageBox.Show(e.Message); } return(parsedData); }
private void CustomerQuery_Load(object sender, EventArgs e) { try { foreach (var item in Customer_Data.getAllCustomers()) { DataGridViewRow row = new DataGridViewRow(); row.CreateCells(dgvCustomers); row.Cells[0].Value = item.id; row.Cells[1].Value = item.name; row.Cells[2].Value = item.lastname; row.Cells[3].Value = item.address; row.Cells[4].Value = item.phone; row.Cells[5].Value = item.email; row.Cells[6].Value = item.dni; dgvCustomers.Rows.Add(row); } } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }