public static List<Customers> GetCustomers() { List<Customers> cumstomerList = new System.Collections.Generic.List<Customers>(); SqlConnection con = new SqlConnection(GetConnectionString()); string sel = "SELECT Email,Name,PassWord,Address,CardNo,CardName,Spent,PhoneNumber,ExpireDate " + "FROM Customers ORDER BY Email"; SqlCommand cmd = new SqlCommand(sel, con); con.Open(); SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); Customers customer; while (dr.Read()) { customer = new Customers(); customer.Email = dr["Email"].ToString(); customer.Name = dr["Name"].ToString(); customer.PassWord = dr["PassWord"].ToString(); customer.Address = dr["Address"].ToString(); customer.CardNo = dr["CardNo"].ToString(); customer.CardName = dr["CardName"].ToString(); customer.Spent = dr["Spent"].ToString(); customer.PhoneNumber = dr["PhoneNumber"].ToString(); customer.ExpireDate = dr["ExpireDate"].ToString(); cumstomerList.Add(customer); } dr.Close(); return cumstomerList; }
protected void ChckCustId() { string cust_id = Request.QueryString["cust_id"]; if (cust_id != null) { Customers ChckCust = new Customers(); bool result = ChckCust.ChckCustById(Convert.ToInt32(cust_id)); bool CustNb = ChckCust.ChckCustNetBankingById(Convert.ToInt32(cust_id)); if (result != false) { if (CustNb != false) { Panel2.Visible = true; Panel1.Visible = false; NetBanking NBCustDataById = NetBanking.NBData_ByCustId(Convert.ToInt32(cust_id)); if (NBCustDataById.NB_Status == "1") { ButtonAllowNB.Visible = false; } } else { Panel1.Visible = true; } } else { Panel1.Visible = true; } } }
/// <summary> /// Method which loads the gridview with all the Customers. /// </summary> protected void loadGridView() { Customers customer = new Customers(); GridView1.DataSource = customer.getAllCustomers(); GridView1.DataBind(); }
/// <summary> /// Loads the page and analizes the QueryString to catch de GET vars. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { try { if (Request.QueryString.Get("id") != null) { int idRoute = Convert.ToInt16(Request.QueryString.Get("id")); Routes route = new Routes(); DataTable dt; dt = route.getRouteByID(idRoute); if (dt != null && dt.Columns[0].Caption == "Router_Dont_Exists") { Response.Redirect(webURL + "views/routes/viewallroutes.aspx"); } else if (dt.Rows.Count == 1) { this.routeid = dt.Rows[0].ItemArray[0].ToString(); this.name = dt.Rows[0].ItemArray[1].ToString(); DetailsView1.DataSource = dt; DetailsView1.DataBind(); if (DetailsView1.Rows[2].Cells[1].Text == " ") { DetailsView1.Rows[2].Cells[1].Text = "<a href=\"" + webURL + "views/routes/assignroutes.aspx\">Asignar</a>"; } Customers customers = new Customers(); dt = customers.getCustomersAndAddressesByRoute(Convert.ToInt16(this.routeid)); if (dt != null && dt.Rows.Count > 0 ) { showCustomers = true; GridView1.DataSource = dt; GridView1.DataBind(); } else { showCustomers = false; } } else { Response.Redirect(webURL + "views/routes/viewallroutes.aspx"); } } else { Response.Redirect(webURL + "views/routes/viewallroutes.aspx"); } } catch (Exception ex) { Response.Redirect(webURL + "views/routes/viewallroutes.aspx"); } }
/// <summary> /// Loads all the Customers and its Addresses on the gridview /// </summary> protected void loadCustomers(int idRoute) { Customers customers = new Customers(); DataTable dt; dt = customers.getCustomersAndAddressesToEdit(idRoute); if (dt != null && dt.Rows.Count > 0) { showCustomers = true; GridView1.DataSource = dt; GridView1.DataBind(); } else { showCustomers = false; } DataTable addressesByRoute; addressesByRoute = customers.getCustomersAndAddressesByRoute(idRoute); for (int i = 0; i < addressesByRoute.Rows.Count; i++) { this.idAddressesByRoute.Add(addressesByRoute.Rows[i].ItemArray[0].ToString()); } this.setDataToScript(this.idAddressesByRoute); }
public void FindCustomersTestBlankString() { Customers target = new Customers {new Customer() { CustomerId = 1, FirstName="Rosie", LastName = "Cotton", EmailAddress = "*****@*****.**"}, new Customer() { CustomerId = 2, FirstName="Bilbo", LastName = "Baggins", EmailAddress = "*****@*****.**"}, new Customer() { CustomerId = 3, FirstName="Frodo", LastName = "Baggins", EmailAddress = "*****@*****.**"}}; string customerName = " "; List<Customer> expected = null; List<Customer> actual; actual = target.FindCustomers(customerName); Assert.AreEqual(expected, actual); }
public void DeleteCustomer(Customers cus) { Customers customer = db.Customers.Find(cus.CustomerID); db.Customers.Remove(customer); db.SaveChanges(); }
public static void AuthorizeOrder(dynamic customer, dynamic order) { dynamic itemTable = new OrderItems(); dynamic productionsTable = new Productions(); dynamic customersTable = new Customers(); //loop the items and set auth accordingly foreach (var item in itemTable.Find(OrderID:order.ID)) { if (item.SKU == "monthly") { //bump the customer's streaming if (customer.StreamUntil < DateTime.Today.AddMonths(-1)) customer.StreamUntil = DateTime.Today.AddMonths(-1); customer.StreamUntil = customer.StreamUntil.AddMonths(1); customersTable.Update(customer,customer.ID); } else if (item.SKU == "yearly") { if (customer.StreamUntil < DateTime.Today.AddYears(-1)) customer.StreamUntil = DateTime.Today.AddYears(-1); if (customer.DownloadUntil < DateTime.Today.AddYears(-1)) customer.DownloadUntil = DateTime.Today.AddYears(-1); customer.StreamUntil = customer.StreamUntil.AddYears(1); customer.DownloadUntil = customer.DownloadUntil.AddYears(1); customersTable.Update(customer,customer.ID); } else { Authorize(customer, productionsTable.First(Slug: item.SKU)); } } }
/// <summary> /// 此方法用于修改客户信息 /// </summary> /// <param name="obj"></param> /// <returns></returns> public static bool CustomerEdit(Customers obj) { List<SqlParameter> list = new List<SqlParameter> { new SqlParameter("@CusAddress",obj.CusAddress), new SqlParameter("@CusZip",obj.CusZip), new SqlParameter("@CusFax",obj.CusFax), new SqlParameter("@CusWebsite",obj.CusWebsite), new SqlParameter("@CusLicenceNo",obj.CusLicenceNo), new SqlParameter("@CusChieftain",obj.CusChieftain), new SqlParameter("@CusBankroll",obj.CusBankroll), new SqlParameter("@CusTurnover",obj.CusTurnover), new SqlParameter("@CusBank",obj.CusBank), new SqlParameter("@CusBankNo",obj.CusBankNo), new SqlParameter("@CusLocalTaxNo",obj.CusLocalTaxNo), new SqlParameter("@CusNationalTaxNo",obj.CusNationalTaxNo), new SqlParameter("@CusID",obj.CusID) }; string sql = @"update Customers set CusAddress=@CusAddress , CusZip=@CusZip , CusFax=@CusFax , CusWebsite=@CusWebsite , CusLicenceNo=@CusLicenceNo , CusChieftain=@CusChieftain , CusBankroll=@CusBankroll , CusTurnover=@CusTurnover , CusBank=@CusBank , CusBankNo=@CusBankNo , CusLocalTaxNo=@CusLocalTaxNo , CusNationalTaxNo=@CusNationalTaxNo where CusID=@CusID "; return DBHelp.ExecuteCUD(sql, list) > 0; }
public Customers Save(Customers entity) { if(entity.Id==0) { var ret = this.context.Customers.Add(entity); this.context.SaveChanges(); return ret; }else { Customers data = GetById(entity.Id); data.CustomerCode = entity.CustomerCode; data.CompanyName = entity.CompanyName; data.ContactName = entity.ContactName; data.ContactTitle = entity.ContactTitle; data.Address = entity.Address; data.CountryID = entity.CountryID; data.CityID = entity.CityID; data.RegionID = entity.RegionID; data.PostalCode = entity.PostalCode; data.Phone = entity.Phone; data.Fax = entity.Fax; data.UpdateBy = entity.UpdateBy; data.UpdateDate = DateTime.Now; data.DemoGraphics = entity.DemoGraphics; this.context.SaveChanges(); return data; } }
protected void btnConfirm_Click(object sender, EventArgs e) { if (!chkUser.Checked) { Response.Write("<script LANGUAGE='JavaScript' >alert('You should accpet our license to register in our website!')</script>"); } else { if (this.IsValid && this.IsPostBack) { Customers customer = new Customers(); customer.Email = txtEmail.Text; customer.Name = txtName.Text; customer.PassWord = txtPassWord2.Text; customer.Address = txtAddress.Text; customer.CardNo = txtCardNo.Text; customer.CardName = txtCardName.Text; customer.PhoneNumber = txtPhoneNumber.Text; customer.ExpireDate = txtExpireDate.Text; customer.Spent = "0"; CustomersDB.InsertCustomer(customer); Application["AccountEmail"] = txtEmail.Text; Session["AccountEmail"] = txtEmail.Text; Response.Redirect("AccountPage.aspx"); } } }
public IHttpActionResult PostCustomers(Customers customers) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Customers.Add(customers); try { db.SaveChanges(); } catch (DbUpdateException) { if (CustomersExists(customers.CustomerID)) { return Conflict(); } else { throw; } } return CreatedAtRoute("DefaultApi", new { id = customers.CustomerID }, customers); }
public List<Customers> GetCustomersByState(string state) { using (var conn = new SqlConnection(_connectionString)) { conn.Open(); var cmd = new SqlCommand(@" Select * from Customers Where State = @state ",conn); cmd.Parameters.Add("@state",SqlDbType.NVarChar, 50).Value = state; using (var rd = cmd.ExecuteReader()) { while(rd.Read()) { var c = new Customers { CustomerID = (int)rd["CustomerID"], FirstName = (string)rd["FirstName"], LastName = (string)rd["LastName"], Address = (string)rd["Address"] }); } } } }
static void Main(string[] args) { // ---------- STRUCTS ---------- Customers bob = new Customers(); bob.createCust("Bob", 15.50, 12345); bob.showCust(); Console.WriteLine("Press Enter to terminate..."); Console.Read(); }
static void Main(string[] args) { // ---------- STRUCTS ---------- Customers bob = new Customers(); bob.createCust("Bob", 15.50, 12345); bob.showCust(); //-See more at: http://www.newthinktank.com/2015/07/learn-c-one-video/#sthash.aY8Gro6z.dpuf }
protected void cuvEmail_ServerValidate(object source, ServerValidateEventArgs args) { args.IsValid = true; List<Customers> customerList = CustomersDB.GetCustomers(); Customers customer = new Customers(); foreach (Customers cus in customerList) { if (txtEmail.Text == cus.Email) { args.IsValid = false; } } }
public void SetUp() { validRequest = new Customers { Id = 1, FirstName = "FirstName", LastName = "LastName", Address = "12345 Address St, New York", Company = "Company", Discount = 10, HasDiscount = true, Postcode = "11215", }; }
public void FindCustomersTestValidString() { var target = new Customers {new Customer() { CustomerId = 1, FirstName="Rosie", LastName = "Cotton", EmailAddress = "*****@*****.**"}, new Customer() { CustomerId = 2, FirstName="Bilbo", LastName = "Baggins", EmailAddress = "*****@*****.**"}, new Customer() { CustomerId = 3, FirstName="Frodo", LastName = "Baggins", EmailAddress = "*****@*****.**"}}; string searchString = "agg"; List<Customer> expected = new List<Customer> {new Customer() { CustomerId = 2, FirstName="Bilbo", LastName = "Baggins", EmailAddress = "*****@*****.**"}, new Customer() { CustomerId = 3, FirstName="Frodo", LastName = "Baggins", EmailAddress = "*****@*****.**"}}; List<Customer> actual; actual = target.FindCustomers(searchString); TestContext.WriteLine(searchString); Debug.WriteLine("Using Debug: " + searchString); Assert.AreEqual(expected.Count, actual.Count); foreach (Customer item in actual) { TestContext.WriteLine(item.ToString()); // Find the item in the expected list Customer expectedItem = expected.FirstOrDefault(c => c.CustomerId == item.CustomerId); Assert.AreEqual(expectedItem.LastName, item.LastName); Assert.AreEqual(expectedItem.FirstName, item.FirstName); Assert.AreEqual(expectedItem.EmailAddress, item.EmailAddress); } }
protected void ButtonSubmit_Click(object sender, EventArgs e) { int CustID = Convert.ToInt32(TextBoxCustId.Text); Customers ChckCustID = new Customers(); bool ChckCust = ChckCustID.ChckCustById(CustID); bool ChckCustNB = ChckCustID.ChckCustNetBankingById(CustID); if(ChckCust != true) { LabelError.Text = "You enter wrong customer ID."; } else if (ChckCustNB != false) { LabelError.Text = "You already apply for it."; } else if (TextBoxPass.Text.Length < 6) { LabelError.Text = "Your password must be at least 6 characters."; } else if (TextBoxPass.Text != TextBoxConfirmPass.Text) { LabelError.Text = "Your confirm password did not match."; } else { Connection con = new Connection(); string strConnString = con.GetConnString(); using (SqlConnection SqlCon = new SqlConnection(strConnString)) { SqlCommand SqlComm = new SqlCommand("", SqlCon); SqlCon.Open(); string ReqDate = DateTime.Now.ToString(); string Status = "0"; string query = string.Format("INSERT INTO net_banking(nb_cid, nb_pass, nb_date, nb_status) VALUES('" + CustID + "', '" + TextBoxPass.Text + "', '" + ReqDate + "', '" + Status + "')"); SqlComm.CommandText = query; SqlComm.ExecuteNonQuery(); /*string SetStatus = string.Format("UPDATE cust_details SET c_net_banking='1' WHERE c_id='" + CustID + "'"); SqlComm.CommandText = SetStatus; SqlComm.ExecuteNonQuery();*/ } Panel1.Visible = false; Panel2.Visible = true; } }
public void Can_Get_Customers_By_State() { //new repository ICustomerRepository customers = new Customers(); //a state that *is* NY var ny = new State("New York", "ny"); //an address in NY var nyAddress = new Address("1", "Main Street", "New York", ny, "12345"); //a state *not* NY var notNy = new State("New Jersey", "nj"); //an address *not* in NY var notNyAddress = new Address("1", "Main Street", "Trenton", notNy, "12345"); //a customer not in NY var notNyCustomer1 = new Customer(); notNyCustomer1.ChangeAddress(notNyAddress); //a customer in NY var nyCustomer1 = new Customer(); nyCustomer1.ChangeAddress(nyAddress); //another customer in NY var nyCustomer2 = new Customer(); nyCustomer2.ChangeAddress(nyAddress); //still one more customer in NY var nyCustomer3 = new Customer(); nyCustomer3.ChangeAddress(nyAddress); //add all the customers to the repository customers.AddCustomer(nyCustomer1); customers.AddCustomer(nyCustomer2); customers.AddCustomer(nyCustomer3); customers.AddCustomer(notNyCustomer1); //select customers from the state that is NY var results = customers.FromState(ny); Assert.That(results, Has.Member(nyCustomer1)); Assert.That(results, Has.Member(nyCustomer2)); Assert.That(results, Has.Member(nyCustomer3)); Assert.That(results.Count(), Is.EqualTo(3)); Assert.That(results, Has.No.Member(notNyCustomer1)); }
/// <summary> /// Load all the data from the database, the last records by Users, Customers, Products & Routes. /// </summary> public void loadAll() { DataTable users = new Users().getLastUsers(); DataTable customers = new Customers().getLastCustomers(); DataTable routes = new Routes().getLastRoutes(); DataTable products = new Products().getLastProducts(); if (users != null && users.Rows.Count > 0) { GridView1.DataSource = users; GridView1.DataBind(); notUsers = false; } else { notUsers = true; } if (customers != null && customers.Rows.Count > 0) { GridView2.DataSource = customers; GridView2.DataBind(); notCustomers = false; } else { notCustomers = true; } if (routes != null && routes.Rows.Count > 0) { GridView3.DataSource = routes; GridView3.DataBind(); notRoutes = false; } else { notRoutes = true; } if (products != null && products.Rows.Count > 0) { GridView4.DataSource = products; GridView4.DataBind(); notProducts = false; } else { notProducts = true; } }
/// <summary> /// Loads all the Customers and its Addresses on the gridview /// </summary> protected void loadCustomers() { Customers customers = new Customers(); DataTable dt = customers.getCustomersAndAddressesToSave(); if (dt != null && dt.Rows.Count > 0) { GridView1.DataSource = dt; GridView1.DataBind(); this.hideGrid = false; } else { this.hideGrid = true; } }
protected void ButtonCustLogin_Click(object sender, EventArgs e) { string CustID = TextBoxCustId.Text; string CustPass = TextBoxPass.Text; Customers ChckCustID = new Customers(); bool ChckCust = ChckCustID.ChckCustById(Convert.ToInt32(CustID)); bool ChckCustNB = ChckCustID.ChckCustNetBankingById(Convert.ToInt32(CustID)); bool ChckCustNBSt = ChckCustID.ChckCustNBStById(Convert.ToInt32(CustID)); if (ChckCust != true) { LabelError.Text = "You entered wrong customer ID."; } else if (ChckCustNB != true) { LabelError.Text = "1st aplly for it."; } else if (ChckCustNBSt != true) { LabelError.Text = "Your request stil panding."; } else { Connection con = new Connection(); string strConnString = con.GetConnString(); using (SqlConnection SqlCon = new SqlConnection(strConnString)) { SqlCommand SqlComm = new SqlCommand("", SqlCon); SqlCon.Open(); string query = string.Format("SELECT nb_pass FROM net_banking WHERE nb_cid='" + Convert.ToInt32(CustID) + "'"); SqlComm.CommandText = query; string dbPass = (String)SqlComm.ExecuteScalar(); if (dbPass == CustPass) { Session["Cust_Id"] = Convert.ToInt32(CustID); Response.Redirect("~/users/Default.aspx"); } else { LabelError.Text = "Wrong password."; } } } }
protected void loadGridView() { Customers customer = new Customers(); DataTable dt = customer.getAllCustomers(0); if (dt != null && dt.Rows.Count > 0) { this.hasCustomers = true; GridView1.DataSource = dt; GridView1.DataBind(); } else { this.hasCustomers = false; this.setNotification("error", "No hay ruta asignada", "No se te ha asignado una ruta y por consecuencia no hay clientes..."); } }
static void Main(string[] args) { Customers customers = new Customers("Boston"); customers.Implementator = new CustomersData(); customers.Show(); customers.Next(); customers.Show(); customers.Next(); customers.Show(); customers.Add("Henry Velasquez"); customers.ShowAll(); // Wait for user Console.ReadKey(); }
/// <summary> /// 此方法用于客户开发成功 /// </summary> /// <param name="cus">要添加的客户对象</param> /// <param name="lm">要添加的联系人对象</param> /// <param name="od">要添加的订单对象</param> /// <param name="act">要添加的交往记录对象</param> /// <returns></returns> public static bool PlanSuccess(int chanID) { Chances chan = ChancesBLL.ChanFindById(chanID); //判断销售机会是否修改成功 if (null == chan) { return false; } List<Plans> plList = PlansDAL.PlanFindByID(chanID); //判断客户开发计划是否为空 if (null == plList) { return false; } //给要添加的客户初始化值 Customers cus = new Customers(); cus.CusID = CustomersBLL.GetCusID(); cus.UserID = chan.ChanDueMan; cus.CusName = chan.ChanName; //给要添加的联系人初始化值 LinkMans lm = new LinkMans(); lm.CusID = cus.CusID; lm.LMName = chan.ChanName; lm.LMMobileNo = lm.LMOfficeNo = chan.ChanLinkTel; //给要添加的订单初始化值 Orders od = new Orders(); od.CusID = cus.CusID; od.OrderDate = "getdate()"; //给要添加的交往记录初始化值 List<Activitys> actList = new List<Activitys>(); for (int i = 0; i < plList.Count; i++) { Activitys act = new Activitys(); act.CusID = cus.CusID; act.ActDate = plList[i].PlanResultDate; act.ActTitle = plList[i].PlanResult; actList.Add(act); } return CustomersBLL.CustomerAddNew(cus) && LinkMansBLL.LinkManAddNew(lm) && OrdersBLL.OrderAddNew(od) && ActivitysBLL.ActivityAddNew(actList) && ChancesBLL.PlanSuccess(chanID); }
/// <summary> /// Loads the page and analizes the QueryString to catch de GET vars. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { try { if (Request.QueryString.Get("id") != null) { int idCustomer = Convert.ToInt16(Request.QueryString.Get("id")); Customers customer = new Customers(); DataTable dt; dt = customer.getCustomerByID(idCustomer); if (dt != null && dt.Columns[0].Caption == "Customer_Dont_Exists") { Response.Redirect(webURL + "views/customers/viewallcustomers.aspx"); } else if (dt.Rows.Count == 1) { this.customerid = dt.Rows[0].ItemArray[0].ToString(); this.name = dt.Rows[0].ItemArray[1].ToString() + " " + dt.Rows[0].ItemArray[2].ToString(); DetailsView1.DataSource = dt; DetailsView1.DataBind(); dt = customer.getCustomerAddresses(idCustomer); GridView1.DataSource = dt; GridView1.DataBind(); } else { Response.Redirect(webURL + "views/customers/viewallcustomers.aspx"); } } else { Response.Redirect(webURL + "views/customers/viewallcustomers.aspx"); } } catch (Exception ex) { Response.Redirect(webURL + "views/customers/viewallcustomers.aspx"); } }
//on save button click protected void SaveBtn_Click(object sender, EventArgs e) { if (IsValid)//checks isValid to confirm that the validators(agentId range,firstname & lastname required) in the aspx did not return a false { CustomerToEdit = new Customers();//sets the object from global scope to a new blank constructor (clearing the object for repurposing) CustomerToEdit.CustomerID = CustId; //get id from global integer (just incase somone was to change this to try to overwrite others information) //fill information from feilds on aspx into the newly cleared object CustomerToEdit.CustFirstName = FirstNameTxt.Text; CustomerToEdit.CustLastName = LastNameTxt.Text; CustomerToEdit.CustAddress = AddressTxt.Text; CustomerToEdit.CustProv = ProvinceTxt.Text; CustomerToEdit.CustCity = CityTxt.Text; CustomerToEdit.CustPostal = PostolCodeTxt.Text; CustomerToEdit.CustCountry = CountryTxt.Text; CustomerToEdit.CustHomePhone = HomePhoneTxt.Text; CustomerToEdit.CustBusPhone = BussinessPhoneTxt.Text; CustomerToEdit.CustEmail = EmailTxt.Text; if (CustomerToEdit.AgentId.ToString().Length > 0) { CustomerToEdit.AgentId = Convert.ToInt32(AgentIdTxt.Text); } else { CustomerToEdit.AgentId = null; } try { if (CustomersDB.UpdateCustomer(CustomerToEdit)) //pass object to static CustomerDB class method UpdateCustomer this returns true on success false on failure (also throws exception so i do not bother with false return) { HttpContext.Current.Response.Write("<SCRIPT LANGUAGE=\"JavaScript\">alert(\"Updated Successfully !\")</SCRIPT>");//inject a javascript alert which will tell user of the saves success Response.Redirect("~/Default.aspx");//then return user to previous page } } catch (Exception ex) { //problem? throw ex; //just throw that exception to the debugger for now } } else { //if not valid, possibly do something else? javascript "Update could not be made?" Exception would catch above this and Exceptions are generally more verbose } }
public static Customers GetCustomer(int CustomerId) { Customers customers = new Customers(); //select customer from customers table SqlConnection Connection = new SqlConnection(); string sel = "SELECT CustomerId, CustFirstName, CustLastName, CustAddress," + "CustCity, CustProv, CustPostal, CustCountry, CustHomePhone, CustBusPhone, CustEmail, AgentId " + "FROM Customers WHERE CustomerId =@CustomerId"; using (Connection = TravelExpertsDB.GetConnection())//connecting from travel data table { using (SqlCommand cmd = new SqlCommand(sel, Connection)) { Connection.Open(); cmd.Parameters.AddWithValue("@CustomerId", CustomerId); SqlDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { customers = new Customers(); customers.CustomerID = (int)dr["CustomerId"]; customers.CustFirstName = dr["CustFirstName"].ToString(); customers.CustLastName = dr["CustLastName"].ToString(); customers.CustAddress = dr["CustAddress"].ToString(); customers.CustCity = dr["CustCity"].ToString(); customers.CustProv = dr["CustProv"].ToString(); customers.CustPostal = dr["CustPostal"].ToString();//Postcode should be validation customers.CustCountry = dr["CustCountry"].ToString(); customers.CustHomePhone = dr["CustHomePhone"].ToString();//Phone number should be validate customers.CustBusPhone = dr["CustBusPhone"].ToString();//phone number should be validate customers.CustEmail = dr["CustEmail"].ToString(); if (dr["AgentId"] != null && dr["AgentId"].ToString().Length > 0) { customers.AgentId = (int)dr["AgentId"]; } } dr.Close(); } } return customers;//return to customers list }
protected void ChckCustId() { string CustId = Request.QueryString["CustId"]; if (CustId != null) { Customers ChckCust = new Customers(); bool result = ChckCust.ChckCustById(Convert.ToInt32(CustId)); if (result != false) { Panel1.Visible = false; Panel2.Visible = true; Connection con = new Connection(); string strConnString = con.GetConnString(); using (SqlConnection SqlCon = new SqlConnection(strConnString)) { SqlCommand SqlComm = new SqlCommand("", SqlCon); SqlCon.Open(); string query = string.Format("SELECT COUNT(*) FROM account WHERE ac_cid='" + Convert.ToInt32(CustId) + "'"); SqlComm.CommandText = query; int ac_result = (int)SqlComm.ExecuteScalar(); if (ac_result == 0) { Panel3.Visible = true; Panel2.Visible = false; } } } else { Panel1.Visible = true; Panel2.Visible = false; } } else { Response.Redirect("Default.aspx"); } }
public Customer FindCustomer(string userName) { return(Customers.Single(c => c.UserName.Equals(userName))); }
public void DisplayAllItems(Customers Cus) { Console.Clear(); Console.WriteLine("================================================================================================"); Console.WriteLine("------------------------------------- DANH SÁCH SẢN PHẨM ---------------------------------------"); Console.WriteLine("================================================================================================\n"); Item_BL IBL = new Item_BL(); List <Items> items = IBL.GetAllItems(); table = new ConsoleTable("Mã sản phẩm", "Tên sản phẩm", "Hãng", "Thuộc tính", "Giá sản phẩm"); foreach (Items i in items) { table.AddRow(i.Produce_Code, i.Item_Name, i.Trademark, i.Attribute, U.FormatMoney(i.Item_Price)); } table.Write(Format.Alternative); string[] choice1 = { "Xem chi tiết sản phẩm", "Thêm vào giỏ hàng", "Quay về trang chính" }; int number1 = Product.SubMenu(null, choice1); switch (number1) { case 1: Console.Write("Chọn mã sản phẩm: "); int showdetal = input(Console.ReadLine()); while (IBL.GetItemByProduceCode(showdetal) == null) { string a; Console.WriteLine("Mã sản phẩm không tồn tại!"); Console.Write("Bạn có muốn nhập lại mã sản phẩm không ? (Y/N): "); a = Console.ReadLine().ToUpper(); while (true) { if (a != "Y" && a != "N") { Console.Write("Bạn chỉ được nhập (Y/N): "); a = Console.ReadLine().ToUpper(); continue; } break; } if (a == "Y" || a == "y") { Console.Write("\nChọn mã sản phẩm: "); showdetal = input(Console.ReadLine()); } else { DisplayProduct(Cus); } } DisplayItemDetails(showdetal, Cus); break; case 2: Console.Write("Chọn mã sản phẩm: "); int pc = input(Console.ReadLine()); while (IBL.GetItemByProduceCode(pc) == null) { string a; Console.WriteLine("Mã sản phẩm không tồn tại!"); Console.Write("Bạn có muốn nhập lại mã sản phẩm không ? (Y/N): "); a = Console.ReadLine().ToUpper(); while (true) { if (a != "Y" && a != "N") { Console.Write("Bạn chỉ được nhập (Y/N): "); a = Console.ReadLine().ToUpper(); continue; } break; } if (a == "Y" || a == "y") { Console.Write("\nChọn mã sản phẩm: "); pc = input(Console.ReadLine()); } else { DisplayProduct(Cus); } } Items item = IBL.GetItemByProduceCode(pc); InputQuantity(Cus, item, pc); break; case 3: U.UserMenu(Cus); break; } }
public IActionResult Create([Bind(nameof(Customers.FirsNamae), nameof(Customers.FirsNamae))] Customers customer) //public IActionResult Create(Customers customer) { return(View("Index", customer)); }
partial void DeleteCustomers(Customers instance);
partial void UpdateCustomers(Customers instance);
public void AddToCustomers(Customers customers) { base.AddObject("Customers", customers); }
public static Customer Map(Customers cust) { throw new NotImplementedException(); }
public ActionResult Customers(int id) { var customer = new Customers().Single(id); return(View(customer)); }
public bool CreateContract(Contract contract, Customers cus) { return(contractDAL.CreateContract(contract, cus)); }
public IQueryable <Customer> Customers2() { return(Customers.Where(c => true)); }
public CustomersBinding(HotDogCart cart, Customers customers) { _cart = cart; _customers = customers; }
public void Update(Customers customers) { _customersRepository.Update(customers); _unitOfWork.Complete(); }
public IResult Update(Customers customer) { _customerDal.Update(customer); return(new SuccessResult(Messages.Updated)); }
public IResult Delete(Customers customer) { _customerDal.Delete(customer); return(new SuccessResult(Messages.Deleted)); }
public void DeleteSelectedRows() { Selection.ToList().ForEach(item => Customers.Remove(item)); }
public void DisplayTradeMark(Customers Cus) { Console.Clear(); string[] choice = { "Urbanista", "MEE", "RHA AUDIO", "jabees", "SONY", "SOMIC", "Sennheiser", "Audio Technica", "Skullcandy", "Ausdom", "1More", "Trở về danh sách sản phẩm", }; int number = SubMenu("Danh sách sản phẩm theo hãng", choice); Item_BL IBL = new Item_BL(); List <Items> items = new List <Items>(); string trade = null; switch (number) { case 1: items = IBL.GetItemByTradeMark("Urbanista"); trade = "Urbanista"; break; case 2: items = IBL.GetItemByTradeMark("MEE"); trade = "MEE"; break; case 3: items = IBL.GetItemByTradeMark("RHA AUDIO"); trade = "RHA AUDIO"; break; case 4: items = IBL.GetItemByTradeMark("jabees"); trade = "jabees"; break; case 5: items = IBL.GetItemByTradeMark("SONY"); trade = "SONY"; break; case 6: items = IBL.GetItemByTradeMark("SOMIC"); trade = "SOMIC"; break; case 7: items = IBL.GetItemByTradeMark("Sennheiser"); trade = "Sennheiser"; break; case 8: items = IBL.GetItemByTradeMark("Audio Technica"); trade = "Audio Technica"; break; case 9: items = IBL.GetItemByTradeMark("Skullcandy"); trade = "Skullcandy"; break; case 10: items = IBL.GetItemByTradeMark("Ausdom"); trade = "Ausdom"; break; case 11: items = IBL.GetItemByTradeMark("1More"); trade = "1More"; break; case 12: DisplayProduct(Cus); break; } Console.Clear(); table = new ConsoleTable("Mã sản phẩm", "Tên sản phẩm", "Hãng", "Thuộc tính", "Giá sản phẩm"); foreach (Items i in items) { table.AddRow(i.Produce_Code, i.Item_Name, i.Trademark, i.Attribute, U.FormatMoney(i.Item_Price)); } table.Write(Format.Alternative); string[] choice1 = { "Xem chi tiết sản phẩm", "Thêm vào giỏ hàng", "Quay về trang chính" }; int number1 = Product.SubMenu(null, choice1); switch (number1) { case 1: Console.Write("Chọn mã sản phẩm: "); int showdetal = input(Console.ReadLine()); while (IBL.GetItemByProduceCodeAndTradeMark(showdetal, trade) == null) { string a; Console.WriteLine("Mã sản phẩm không tồn tại!"); Console.Write("Bạn có muốn nhập lại mã sản phẩm không ? (Y/N): "); a = Console.ReadLine().ToUpper(); while (true) { if (a != "Y" && a != "N") { Console.Write("Bạn chỉ được nhập (Y/N): "); a = Console.ReadLine().ToUpper(); continue; } break; } if (a == "Y" || a == "y") { Console.Write("\nChọn mã sản phẩm: "); showdetal = input(Console.ReadLine()); } else { DisplayProduct(Cus); } } DisplayItemDetails(showdetal, Cus); break; case 2: Console.Write("Chọn mã sản phẩm: "); int pc = input(Console.ReadLine()); while (IBL.GetItemByProduceCodeAndTradeMark(pc, trade) == null) { string a; Console.WriteLine("Mã sản phẩm không tồn tại!"); Console.Write("Bạn có muốn nhập lại mã sản phẩm không ? (Y/N): "); a = Console.ReadLine().ToUpper(); while (true) { if (a != "Y" && a != "N") { Console.Write("Bạn chỉ được nhập (Y/N): "); a = Console.ReadLine().ToUpper(); continue; } break; } if (a == "Y" || a == "y") { Console.Write("\nChọn mã sản phẩm: "); pc = input(Console.ReadLine()); } else { DisplayProduct(Cus); } } Items item = IBL.GetItemByProduceCodeAndTradeMark(pc, trade); InputQuantity(Cus, item, pc); break; case 3: U.UserMenu(Cus); break; } }
public ActionResult ProjectDitail(int id) { _context = new ApplicationDbContext(); Session["id"] = id; Projects project = _context.Projects.FirstOrDefault(gr => gr.Id == id); if (project == null) { return(RedirectToAction("Index", "MyProject")); } Customers customer = _context.Customers.FirstOrDefault(c => c.Id == project.Customer); List <Customers> customersList = _context.Customers.Select(c => c).ToList <Customers>(); List <Groups> groupList = _context.Groups.Select(g => g).ToList <Groups>(); var projectGroup = (from u in _context.Groups.ToList() from gu in _context.ProjectsGroups.ToList() where gu.ProjId == @project.Id && gu.GroupId == u.Id select u).ToList(); /////files CloudBlobContainer container = GetCloudBlobContainer(); string con = container.Name; List <string> blobs = new List <string>(); int sessionData = (int)Session["id"]; string projectID = Convert.ToString(sessionData); foreach (IListBlobItem item in container.ListBlobs(useFlatBlobListing: true)) { //if(item.Parent.Container.Name == "8") if (item.GetType() == typeof(CloudBlockBlob)) { CloudBlockBlob blob = (CloudBlockBlob)item; string[] namePart = blob.Name.Split('/'); if (namePart != null && namePart.Count() > 0 && namePart[0] == projectID) { blobs.Add(blob.Name); } } else if (item.GetType() == typeof(CloudPageBlob)) { CloudPageBlob blob = (CloudPageBlob)item; blobs.Add(blob.Name); } else if (item.GetType() == typeof(CloudBlobDirectory)) { CloudBlobDirectory dir = (CloudBlobDirectory)item; blobs.Add(dir.Uri.ToString()); } } /////files var viewModel = new ProjectsFormViewModel { project = project, customer = customer, customers = customersList, groups = groupList, groupsInProject = projectGroup, filelist = blobs }; viewModel.SelectedIDArray = viewModel.groupsInProject.Select(u => u.Id.ToString()).ToArray(); return(View(viewModel)); }
public void DisplayItemDetails(int id, Customers Cus) { Item_BL IBL = new Item_BL(); Items item = IBL.GetItemByProduceCode(id); Console.Clear(); Console.WriteLine("=================================================================================="); Console.WriteLine("-------------------------------- CHI TIẾT SẢN PHẨM -------------------------------\n"); table = new ConsoleTable("Mã sản phẩm", "Tên sản phẩm", "Hãng", "Thuộc tính", "Giá sản phẩm"); table.AddRow(item.Produce_Code, item.Item_Name, item.Trademark, item.Attribute, U.FormatMoney(item.Item_Price)); table.Write(Format.Alternative); Console.WriteLine("Mô tả sản phẩm : {0}\n", item.Item_Description); while (true) { string[] choice = { "Thêm vào giỏ hàng", "Trở về danh sách sản phẩm", "Trở về trang chính" }; int number = SubMenu(null, choice); switch (number) { case 1: InputQuantity(Cus, item, id); break; case 2: DisplayProduct(Cus); break; case 3: if (Cus.User_Name != null && Cus.User_Password != null) { U.UserMenu(Cus); } else { Console.Clear(); Menu m = new Menu(); Product Product = new Product(); string[] choice1 = { "Danh sách sản phẩm", "Xem giỏ hàng", "Đăng nhập", "Thoát" }; int number1 = Product.SubMenu($"Chào mừng đến với cửa hàng", choice1); switch (number1) { case 1: Product.DisplayProduct(Cus); break; case 2: U.DisplayCart(Cus); break; case 3: U.ScreenLogin(); break; case 4: Environment.Exit(0); break; } } break; } } }
public void SelectCustomer(int customerId) { SelectedCustomer = Customers.First(x => x.Id == customerId); }
partial void InsertCustomers(Customers instance);
public async Task ClearAndFillWithDemoData() { await OrderDetails.ForEachAsync(od => OrderDetails.Remove(od)); await Orders.ForEachAsync(o => Orders.Remove(o)); await Customers.ForEachAsync(c => Customers.Remove(c)); await Products.ForEachAsync(p => Products.Remove(p)); var demoCustomers = new[] { new Customer() { CompanyName = "Corina Air Conditioning", CountryIsoCode = "AT" }, new Customer() { CompanyName = "Fernando Engineering", CountryIsoCode = "AT" }, new Customer() { CompanyName = "Murakami Plumbing", CountryIsoCode = "CH" }, new Customer() { CompanyName = "Naval Metal Construction", CountryIsoCode = "DE" } }; Customers.AddRange(demoCustomers); var demoProducts = new[] { new Product() { Description = "Mountain Bike", IsAvailable = true, CategoryCode = "BIKE", PricePerUom = 2500 }, new Product() { Description = "Road Bike", IsAvailable = true, CategoryCode = "BIKE", PricePerUom = 2000 }, new Product() { Description = "Skate Board", IsAvailable = true, CategoryCode = "BOARD", PricePerUom = 100 }, new Product() { Description = "Long Board", IsAvailable = true, CategoryCode = "BOARD", PricePerUom = 250 }, new Product() { Description = "Scooter", IsAvailable = false, CategoryCode = "OTHERS", PricePerUom = 150 } }; Products.AddRange(demoProducts); var rand = new Random(); for (var i = 0; i < 100; i++) { var order = new OrderHeader() { OrderDate = new DateTimeOffset(new DateTime(2014, rand.Next(1, 12), rand.Next(1, 28))), Customer = demoCustomers[rand.Next(demoCustomers.Length - 1)] }; Orders.Add(order); for (var j = 0; j < 3; j++) { OrderDetails.Add(new OrderDetail() { Order = order, Product = demoProducts[rand.Next(demoProducts.Length - 1)], Amount = rand.Next(1, 5) }); } } await SaveChangesAsync(); }
public void DeleteCustomer(Customer customer) { _data.Remove(customer); Customers.Refresh(); }
public DataTable SearchCustomer(Customers search) { return(customerDb.SearchCustomer(search)); }
protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity <Employee>( e => { e.Ignore(em => em.Address); e.Ignore(em => em.BirthDate); e.Ignore(em => em.Extension); e.Ignore(em => em.HireDate); e.Ignore(em => em.HomePhone); e.Ignore(em => em.LastName); e.Ignore(em => em.Notes); e.Ignore(em => em.Photo); e.Ignore(em => em.PhotoPath); e.Ignore(em => em.PostalCode); e.Ignore(em => em.Region); e.Ignore(em => em.TitleOfCourtesy); e.HasOne(e1 => e1.Manager).WithMany().HasForeignKey(e1 => e1.ReportsTo); }); modelBuilder.Entity <Product>( e => { e.Ignore(p => p.CategoryID); e.Ignore(p => p.QuantityPerUnit); e.Ignore(p => p.ReorderLevel); e.Ignore(p => p.UnitsOnOrder); }); modelBuilder.Entity <Order>( e => { e.Ignore(o => o.Freight); e.Ignore(o => o.RequiredDate); e.Ignore(o => o.ShipAddress); e.Ignore(o => o.ShipCity); e.Ignore(o => o.ShipCountry); e.Ignore(o => o.ShipName); e.Ignore(o => o.ShipPostalCode); e.Ignore(o => o.ShipRegion); e.Ignore(o => o.ShipVia); e.Ignore(o => o.ShippedDate); }); modelBuilder.Entity <OrderDetail>( e => { e.HasKey( od => new { od.OrderID, od.ProductID }); }); modelBuilder .Entity <CustomerView>() .HasNoKey() .ToQuery( () => Customers .Select( c => new CustomerView { Address = c.Address, City = c.City, CompanyName = c.CompanyName, ContactName = c.ContactName, ContactTitle = c.ContactTitle })); modelBuilder .Entity <OrderQuery>() .HasNoKey() .ToQuery( () => Orders .Select( o => new OrderQuery { CustomerID = o.CustomerID })); modelBuilder .Entity <ProductQuery>() .HasNoKey() .ToQuery( () => Products .Where(p => !p.Discontinued) .Select( p => new ProductQuery { ProductID = p.ProductID, ProductName = p.ProductName, CategoryName = "Food" })); modelBuilder .Entity <CustomerQuery>() .HasNoKey() .HasQueryFilter(cq => cq.CompanyName.StartsWith(_searchTerm)) .ToQuery( () => Customers .Include(c => c.Orders) // ignored .Select( c => new CustomerQuery { CompanyName = c.CompanyName, OrderCount = c.Orders.Count(), SearchTerm = _searchTerm })); }
public bool ReturnMotor(Customers customer, Motor motor, Contract contract) { return(contractDAL.ReturnMotor(customer, motor, contract)); }
public List <Customer> GetAllCustomers() { return(Customers.ToList()); }
protected void Page_Load(object sender, EventArgs e) { if (Page.RouteData.Values["Id"] != null) { id = Page.RouteData.Values["Id"] as string; } if (Page.RouteData.Values["groupName"] != null) { groupname = Page.RouteData.Values["groupName"] as string; } if (Session["Info"] != null) { cus = (Customers)Session["Info"]; isLogin = true; DataTable dtCount = DownloadHistoryService.DownloadHistory_GetByUserId(cus.Id); if (dtCount.Rows.Count < 2) { isValidDownload = true; } } try { if (Microsoft.VisualBasic.Information.IsNumeric(id)) { DataTable pro = ProductService.Product_GetById(id); if (pro.Rows.Count > 0) { name = pro.Rows[0]["Name"].ToString(); Page.Title = name; content = pro.Rows[0]["Content"].ToString(); ltrDetail.Text = pro.Rows[0]["Detail"].ToString(); sImage_01 = pro.Rows[0]["Image1"].ToString(); sPrice = pro.Rows[0]["Price"].ToString(); hdPrice.Value = sPrice; if (sPrice.IndexOf(",") > -1) { sPrice = sPrice.Split(Char.Parse(","))[0]; } if (pro.Rows[0]["IsSpecial"].ToString() == "1") { isShowDownload = true; } if (!IsPostBack) { string strSize = pro.Rows[0]["Image5"].ToString(); string[] lSize; if (strSize.IndexOf(",") > -1) { lSize = strSize.Split(Char.Parse(",")); } else { lSize = new string[] { strSize }; } for (int i = 0; i < lSize.Length; i++) { if (lSize[i] == string.Empty) { continue; } ddlSize.Items.Add(new ListItem(lSize[i], lSize[i])); } ddlSize.DataBind(); ddlSize.SelectedIndex = 0; //Hiển thị sản phẩm tương tự List <GroupProduct> lstG = GroupProductService.GroupProduct_GetById(pro.Rows[0]["GroupId"].ToString()); string itemCnt = string.Empty; if (lstG.Count > 0) { itemCnt = lstG[0].Items; } if (string.IsNullOrEmpty(itemCnt) || itemCnt == "0") { itemCnt = "3"; } DataTable dtRelated = ProductService.Product_GetByTop((Int16.Parse(itemCnt) * 2).ToString(), "Active = 1 AND GroupId='" + pro.Rows[0]["GroupId"].ToString() + "' AND Id <> '" + id + "'", "Ord"); if (dtRelated.Rows.Count > 0) { HttpCookie cookie = Request.Cookies[Consts.GUID_SHOPPING_CART]; switch (itemCnt) { case "4": rptProducts04.DataSource = StringClass.ModifyDataProduct(dtRelated, cookie); rptProducts04.DataBind(); break; default: rptProducts.DataSource = StringClass.ModifyDataProduct(dtRelated, cookie); rptProducts.DataBind(); break; } } } } } } catch (Exception ex) { MailSender.SendMail("", "", "Error System", ex.Message + "\n" + ex.StackTrace); } }
public void AddCustomer(Customer customer) { _data.Add(customer); Customers.Refresh(); Customers.MoveCurrentTo(customer); }
public void DisplayAttribute(Customers Cus) { Console.Clear(); Item_BL IBL = new Item_BL(); User U = new User(); string[] choice = { "Không dây", "Thể thao", "In-Ear", "Gaming", "Earbud", "Trở về danh sách sản phẩm" }; int number = SubMenu("Danh sách sản phẩm theo thuộc tính", choice); List <Items> items = new List <Items>(); string ab = null; switch (number) { case 1: items = IBL.GetItemByAttribute("Không dây"); ab = "Không dây"; break; case 2: items = IBL.GetItemByAttribute("Thể thao"); ab = "Thể thao"; break; case 3: items = IBL.GetItemByAttribute("In-Ear"); ab = "In-Ear"; break; case 4: items = IBL.GetItemByAttribute("Gaming"); ab = "Gaming"; break; case 5: items = IBL.GetItemByAttribute("Earbud"); ab = "Earbud"; break; case 6: DisplayProduct(Cus); break; } Console.Clear(); table = new ConsoleTable("Mã sản phẩm", "Tên sản phẩm", "Hãng", "Thuộc tính", "Giá sản phẩm"); foreach (Items i in items) { table.AddRow(i.Produce_Code, i.Item_Name, i.Trademark, i.Attribute, U.FormatMoney(i.Item_Price)); } table.Write(Format.Alternative); string[] choice1 = { "Xem chi tiết sản phẩm", "Thêm vào giỏ hàng", "Quay về trang chính" }; int number1 = Product.SubMenu(null, choice1); switch (number1) { case 1: Console.Write("Chọn mã sản phẩm: "); int showdetal = input(Console.ReadLine()); while (IBL.GetItemByProduceCodeAndAttribute(showdetal, ab) == null) { string a; Console.WriteLine("Mã sản phẩm không tồn tại!"); Console.Write("Bạn có muốn nhập lại mã sản phẩm không ? (Y/N): "); a = Console.ReadLine().ToUpper(); while (true) { if (a != "Y" && a != "N") { Console.Write("Bạn chỉ được nhập (Y/N): "); a = Console.ReadLine().ToUpper(); continue; } break; } if (a == "Y" || a == "y") { Console.Write("\nChọn mã sản phẩm: "); showdetal = input(Console.ReadLine()); } else { DisplayProduct(Cus); } } DisplayItemDetails(showdetal, Cus); break; case 2: Console.Write("Chọn mã sản phẩm: "); int pc = input(Console.ReadLine()); while (IBL.GetItemByProduceCodeAndAttribute(pc, ab) == null) { string a; Console.WriteLine("Mã sản phẩm không tồn tại!"); Console.Write("Bạn có muốn nhập lại mã sản phẩm không ? (Y/N): "); a = Console.ReadLine().ToUpper(); while (true) { if (a != "Y" && a != "N") { Console.Write("Bạn chỉ được nhập (Y/N): "); a = Console.ReadLine().ToUpper(); continue; } break; } if (a == "Y" || a == "y") { Console.Write("\nChọn mã sản phẩm: "); pc = input(Console.ReadLine()); } else { DisplayProduct(Cus); } } Items item = IBL.GetItemByProduceCodeAndAttribute(pc, ab); InputQuantity(Cus, item, pc); break; case 3: U.UserMenu(Cus); break; } }
public void DeleteCustomer(Customer customer20) { Customers.Remove(customer20); SaveChanges(); Console.WriteLine("Customer " + customer20.CustomerId + " Deleted"); }