public static void Query5() { InitializeMapperQ5(); using (var db = new CarDealerContext()) { var xmlDoc = new XDocument(); var customers = new CustomersDTO() { Customers = db.Customers .ProjectTo <CustomerDTO>() .Where(c => c.BoughtCars >= 1) .OrderByDescending(c => c.SpentMoney).ThenByDescending(c => c.BoughtCars) .ToList() }; var serializer = new XmlSerializer(typeof(CustomersDTO)); var writer = new StreamWriter("../../Export/customers-total-sales.xml"); using (writer) { serializer.Serialize(writer, customers); } } }
//Xem public List <CustomersDTO> View() { List <CustomersDTO> users = new List <CustomersDTO>(); try { string query = "select * from Customers"; DataTable dt = DataProvider.Instance.Select(CommandType.Text, query); foreach (DataRow item in dt.Rows) { string id = item["CustomerID"].ToString(); string cpnName = item["CompanyName"].ToString(); string ctcName = item["ContactName"].ToString(); string ctcTitle = item["ContactTitle"].ToString(); string addr = item["Address"].ToString(); string city = item["City"].ToString(); string region = item["Region"] == null ? null : item["Region"].ToString(); string posCode = item["PostalCode"] == null ? null : item["PostalCode"].ToString(); string country = item["Country"].ToString(); string phone = item["Phone"].ToString(); string fax = item["Fax"] == null ? null : item["Fax"].ToString(); CustomersDTO newU = new CustomersDTO(id, cpnName, ctcName, ctcTitle, addr, city, region, posCode, country, phone, fax); users.Add(newU); } return(users); } catch (SqlException ex) { throw ex; } }
public async Task <IActionResult> UpdateCustomer(long id, CustomersDTO customersDTO) { if (id != customersDTO.Id) { return(BadRequest()); } var customers = await _context.Customers.FindAsync(id); if (customers == null) { return(NotFound()); } customers.Name = customersDTO.Name; customers.Email = customersDTO.Email; customers.Address = customersDTO.Address; customers.Phone = customersDTO.Phone; customers.Pass = customersDTO.Pass; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) when(!CustomerExists(id)) { return(NotFound()); } return(NoContent()); }
private void btn_luu_customer_Click_1(object sender, EventArgs e) { string a; if (check_erro() == true) { if (Radio_Nam.Checked == true) { a = Radio_Nam.Text; } else { a = Radio_Nu.Text; } CustomersDTO b = new CustomersDTO(tb_makh.Text, tb_ten_kh.Text, date_kh.Value, tb_dia_chi.Text, tb_phone.Text, a); if (CustomersBUS.Instance.insert_customer(b)) { MessageBox.Show("Thêm thành công"); } else { MessageBox.Show("Thêm không thành công"); } this.Close(); } }
public void CustomerSelect(CustomersDTO customers) { if (customers != null) { txt_CustomerName.EditValue = __dll_SaleOwner.CustomerName = customers.name; } }
private void do_Form(CustomersDTO Customers) { Form _Form = MspTool.get_OpenForm("frmSatis"); if (_Form != null) { ((frmSatis)_Form).CustomerSelect(Customers); } _Form = null; }
public static ResponseDTO <CustomersDTO> RegisterCustomer(CustomersDTO customer) { var newCustomerLogic = new CustomersLogic(); var response = newCustomerLogic.CustomerExecute(new RequestDTO <CustomersDTO> { Item = customer }); return(response); }
public void MusteriSec() { CustomersDTO Orow = (CustomersDTO)gcvCustomers.GetFocusedRow(); if (Orow != null) { do_Form(Orow); this.Close(); } }
public CustomersDTO CustomerGetItem(string phoneNumber) { var customer = new CustomersDTO(); using (SqlCommand command = new SqlCommand("Usp_Customers_GETI")) { command.Parameters.Add("@CustomerPhoneNumber", SqlDbType.VarChar).Value = phoneNumber; customer = command.Select(reader => reader.ToCustomer()).FirstOrDefault(); } return(customer); }
private void CustomersSeaNameSurTE_EditValueChanged(object sender, EventArgs e) { void Show(string name) { CustomersSeaNameSurTE.Text = name; __customer = _repository.Run <CustomerTransactionsService, CustomersDTO>(x => x.GetCustomerFromName(name)); bs_CustomersSea.DataSource = __customer; this.ShowDialog(); } }
private void bbi_VeresiyeDefter_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { CustomersDTO Orow = (CustomersDTO)gcvCustomers.GetFocusedRow(); if (Orow != null) { frmMusterVeresiyeDetail frm = new frmMusterVeresiyeDetail(); frm.musteriAdi = Orow.name; frm.ShowDialog(); } }
public IActionResult Update([FromBody] CustomersDTO customer) { if (customer == null) { return(BadRequest()); } var response = _customersApplication.Update(customer); if (response.IsSuccess) { return(Ok(response)); } return(BadRequest(response.Message)); }
public async Task <IActionResult> UpdateAsync([FromBody] CustomersDTO customer) { if (customer == null) { return(BadRequest()); } var response = await _customersApplication.UpdateAsync(customer); if (response.IsSuccess) { return(Ok(response)); } return(BadRequest(response.Message)); }
public void Show(int id) { if (_FormOpenType == FormOpenType.New) { __customers = new CustomersDTO(); } if (_FormOpenType == FormOpenType.Edit) { __customers = _repository.Run <CustomerService, CustomersDTO>(x => x.GetCustomer(id)); } bs_CustomersEdit.DataSource = __customers; this.ShowDialog(); }
private void btnRemCustomer_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (!MspTool.PermissionControl(AppMain.User.username, SecRightType.Delete, (int)DocumentType.MusteriList, AppMain.CompanyRecId)) return; CustomersDTO oRow = (CustomersDTO)gcvCustomers.GetFocusedRow(); if (oRow != null) { if (get_Question("Kayıt Silinecektir. Onaylıyor musunuz?")) { var result = _repository.Run<CustomerService, ActionResponse<CustomersDTO>>(x => x.DeleteCostumers(oRow.id)); do_refresh(); } } }
public void do_Edit() { if (!MspTool.PermissionControl(AppMain.User.username, SecRightType.Update, (int)DocumentType.MusteriList, AppMain.CompanyRecId)) return; CustomersDTO Orow = (CustomersDTO)gcvCustomers.GetFocusedRow(); if (Orow != null) { frmCustomerEdit frm = new frmCustomerEdit(); frm._FormOpenType = Infrastructure.FormOpenType.Edit; frm.Show(Orow.id); } }
public IActionResult Insert([FromBody] CustomersDTO customer) { if (customer == null) { return(BadRequest()); } var response = _customerApplication.Insertar(customer); if (response.IsSuccess) { return(Ok(response.Data)); } return(BadRequest(response.Message)); }
public bool CustomerExecute(CustomersDTO customer) { bool isExecuted = default; using (SqlCommand command = new SqlCommand("Usp_Customers_INS")) { command.Parameters.Add("@CompanyId", SqlDbType.BigInt).Value = customer.CompanyIdentifier; command.Parameters.Add("@CustomerName", SqlDbType.VarChar).Value = customer.CustomerName; command.Parameters.Add("@CustomerPhoneNumber", SqlDbType.VarChar).Value = customer.CustomerPhoneNumber; command.Parameters.Add("@CustomerEmail", SqlDbType.VarChar).Value = customer.CustomerEmail; command.Parameters.Add("@CustomerPassword", SqlDbType.VarChar).Value = customer.CustomerPassword; command.Parameters.Add("@CustomerPostalCode", SqlDbType.VarChar).Value = customer.CustomerPostalCode; command.Parameters.Add("@CustomerAddress", SqlDbType.VarChar).Value = customer.CustomerAddress; isExecuted = command.ExecuteQuery(); } return(isExecuted); }
public void DeleteCustomers(CustomersDTO entity) { var customer = customersRepository.GetAll().Where(x => x.CustomerId == entity.CustomerId).FirstOrDefault(); customer.ContactName = entity.ContactName; customer.ContactTitle = entity.ContactTitle; customer.Phone = entity.Phone; customer.Email = entity.Email; customer.Fax = entity.Fax; customer.CompanyName = entity.CompanyName; customer.Address = entity.Address; customer.PostalCode = entity.PostalCode; customer.TerritoryId = entity.TerritoryId; customer.RegionId = entity.RegionId; customer.CountryId = entity.CountryId; customersRepository.Delete(customer); }
public async Task <ActionResult <CustomersDTO> > CreateCategory(CustomersDTO customersDTO) { var customers = new Customers { Name = customersDTO.Name, Email = customersDTO.Email, Address = customersDTO.Address, Phone = customersDTO.Phone, Pass = customersDTO.Pass }; _context.Customers.Add(customers); await _context.SaveChangesAsync(); return(CreatedAtAction( nameof(GetCustomers), new { id = customers.Id }, CustomersitemDTO(customers))); }
public void AddCustomers(CustomersDTO entity) { Customers customers = new Customers { ContactName = entity.ContactName, ContactTitle = entity.ContactTitle, Phone = entity.Phone, Email = entity.Email, Fax = entity.Fax, CompanyName = entity.CompanyName, Address = entity.Address, PostalCode = entity.PostalCode, TerritoryId = entity.TerritoryId, RegionId = entity.RegionId, CountryId = entity.CountryId }; customersRepository.Add(customers); }
public Response <bool> Update(CustomersDTO customer) { var response = new Response <bool>(); try { var customerAux = _mapper.Map <Customers>(customer); response.Data = _customersDomain.Update(customerAux); if (response.Data) { response.IsSuccess = true; response.Message = "Update con exito!"; } } catch (Exception ex) { response.Message = ex.Message; } return(response); }
public Response <bool> Insert(CustomersDTO customersDto) { var response = new Response <bool>(); try { var customer = _mapper.Map <Customers>(customersDto); response.Data = _customersDomain.Insert(customer); if (response.Data) { response.IsSuccess = true; response.Message = "Registro Exitoso!!!"; } } catch (Exception e) { response.Message = e.Message; } return(response); }
public Response <bool> Update(CustomersDTO customersDto) { var response = new Response <bool>(); try { var customer = _mapper.Map <Customers>(customersDto); response.Data = _customersDomain.Update(customer); if (response.Data) { response.IsSuccess = true; response.Message = "Actualización Exitoso!!!"; } } catch (Exception e) { response.Message = e.Message; } return(response); }
public Response <bool> Insert(CustomersDTO customer) { var response = new Response <bool>(); try { var customerAux = _mapper.Map <Customers>(customer); response.Data = _customersDomain.Insert(customerAux); if (response.Data) { response.IsSuccess = true; response.Message = "Registro con exito!"; _appLogger.LogInformation("Exito!"); } } catch (Exception ex) { response.Message = ex.Message; } return(response); }
public async Task <Response <bool> > InsertAsync(CustomersDTO customer) { var response = new Response <bool>(); try { var customerAux = _mapper.Map <Customers>(customer); response.Data = await _customersDomain.InsertAsync(customerAux); if (response.Data) { response.IsSuccess = true; response.Message = "Registro con exito!"; } } catch (Exception ex) { response.Message = ex.Message; } return(response); }
public async Task <Response <bool> > UpdateAsync(CustomersDTO customersDTO) { var response = new Response <bool>(); try { var customer = _mapper.Map <Customer>(customersDTO); response.Data = await _customerDomain.UpdateAsync(customer); if (response.Data) { response.IsSuccess = true; response.Message = "Actualización exitosa!"; } } catch (Exception e) { response.Message = e.Message; } return(response); }
public bool Edit(CustomersDTO a) { int result = 0; try { string query = string.Format("update khach_hang set ten_kh= N'{0}', ngay_sinh= '{1}', dia_chi= N'{2}', dien_thoai= '{3}', gioi_tinh= N'{4}' where makh='{5}'", a.Ten_kh, a.Ngay_sinh, a.Dia_chi, a.Dien_thoai, a.Gioi_tinh, a.Makh); result = ConnectSQL.Instance.ExecuteNonQuery(query); } catch (Exception ex) { MessageBox.Show(ex.Message); } if (result == 0) { return(false); } else { return(true); } }
public bool Insert(CustomersDTO a) { int result = 0; try { string query = string.Format("insert into khach_hang(makh,ten_kh,ngay_sinh,dia_chi,dien_thoai,gioi_tinh) values ('{0}',N'{1}','{2}','{3}','{4}',N'{5}')", a.Makh, a.Ten_kh, a.Ngay_sinh, a.Dia_chi, a.Dien_thoai, a.Gioi_tinh); result = ConnectSQL.Instance.ExecuteNonQuery(query); } catch (Exception ex) { MessageBox.Show("Mã khách hàng đã tồn tại"); } if (result == 0) { return(false); } else { return(true); } }
// Get Detail Customer public async Task <CosApiResponse> GetDetailCustomer(RequestModelBase request) { var response = new CosApiResponse(); try { using (var _db = new CosContext()) { GetDetailCustomerResponse result = new GetDetailCustomerResponse(); /* get Customer */ var customerDB = _db.Customers.Where(o => o.Id == request.ID && o.Status == (byte)Constants.EStatus.Actived).FirstOrDefault(); if (customerDB != null) { var responseUser = new CustomersDTO() { Id = customerDB.Id, Name = customerDB.Name, Email = customerDB.Email, Phone = customerDB.Phone, Active = customerDB.Active, City = customerDB.City, Country = customerDB.Country, }; result.Customer = responseUser; response.Data = result; } else { response.Message = "Unable to find customer"; } NSLog.Logger.Info("Response Get Detail customer", response); } } catch (Exception ex) { NSLog.Logger.Error("Error Get Detail customer", null, response, ex); } finally { /*_db.Refresh();*/ } return(response); }