private void btnSearch_Click(object sender, EventArgs e) { DataSet ds = new DataSet(); try { BranchOfficeDTO objBranch = new BranchOfficeDTO(); objBranch.ID = -1; objBranch.Name = txtName.Text; objBranch.Phone = txtPhone.Text; objBranch.Fax = txtFax.Text; objBranch.IDLocation = Convert.ToInt64((cboLocation.SelectedItem as clsComboItem).Value); ds = BranchOfficeDAO.BranchOffice_Search(objBranch); if (ds != null && ds.Tables.Count > 0) { dgvBranchOffice.DataSource = ds.Tables[0].Copy(); } else { clsMessages.ShowWarning("Không tìm thấy"); } } catch (Exception ex) { clsMessages.ShowErrorException(ex); } finally { ds.Dispose(); } }
private void btnSave_Click(object sender, EventArgs e) { DataSet ds = new DataSet(); try { BranchOfficeDTO obj = new BranchOfficeDTO(); obj.ID = -1; obj.Name = txtName.Text; obj.Phone = txtPhone.Text; obj.Fax = txtFax.Text; obj.IDLocation = Convert.ToInt64((cboLocation.SelectedItem as clsComboItem).Value); ds = BranchOfficeDAO.BranchOffice_InsUpd(obj); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0 && Convert.ToInt32(ds.Tables[0].Rows[0]["Result"]) == 1) { clsMessages.ShowInformation("Thêm thành công!"); frmParent.LoadDataToForm(); this.Close(); } else { clsMessages.ShowWarning("Thêm thất bại!"); } } catch (Exception ex) { clsMessages.ShowErrorException(ex); } finally { ds.Dispose(); } }
/// <summary> /// Metodo para crear una oficina /// </summary> /// <param name="office">Una Oficina DTO o model que se mapea a entidad de datos oficina, se agrega al context y se confirma la operacion</param> /// <returns>La oficina creada y mapeada a Oficina DTO</returns> public BranchOfficeDTO CreateOffice(BranchOfficeDTO office) { var officeEntity = _mapper.Map <BranchOffice>(office); var newOffice = this.Add(officeEntity); this.CommitChanges(); return(_mapper.Map <BranchOfficeDTO>(newOffice)); }
public ActionResult Update(BranchOfficeDTO branchOfficeDTO) { BranchOffice branchOffice = branchOfficeService.GetByID(branchOfficeDTO.ID); branchOffice.Name = branchOfficeDTO.Name; branchOffice.Adress = branchOfficeDTO.Adress; branchOffice.Email = branchOfficeDTO.Email; branchOffice.Fax = branchOfficeDTO.Fax; branchOffice.GoogleMap = branchOfficeDTO.GoogleMap; branchOffice.ImageUrl = branchOfficeDTO.ImageUrl; branchOffice.Phone = branchOfficeDTO.Phone; branchOfficeService.Update(branchOffice); return(Redirect("/SysAdmin/BranchOffice/List")); }
public static DataSet BranchOffice_InsUpd(BranchOfficeDTO _BranchOffice) { DataSet ds = new DataSet(); try { ds = clsDatabaseExecute.ExecuteDatasetSP("BranchOffice_InsUpd", _BranchOffice.ID, _BranchOffice.Name, _BranchOffice.Phone, _BranchOffice.Fax, _BranchOffice.IDLocation); } catch (Exception ex) { clsMessages.ShowErrorException(ex); } return(ds); }
public ActionResult Update(int id) { BranchOffice branchOffice = branchOfficeService.GetByID(id); BranchOfficeDTO branchOfficeDTO = new BranchOfficeDTO() { Name = branchOffice.Name, Adress = branchOffice.Adress, Email = branchOffice.Email, Fax = branchOffice.Fax, GoogleMap = branchOffice.GoogleMap, ImageUrl = branchOffice.ImageUrl, UserID = branchOffice.UserID, Phone = branchOffice.Phone, ID = branchOffice.ID }; return(View(branchOfficeDTO)); }
private void btnSave_Click(object sender, EventArgs e) { DataSet ds = new DataSet(); try { BranchOfficeDTO obj = new BranchOfficeDTO(); if (string.IsNullOrWhiteSpace(txtID.Text)) { clsMessages.ShowInformation("Vui lòng chọn dòng dữ liệu muốn sửa!"); return; } obj.ID = Convert.ToInt64(txtID.Text); obj.Name = txtName.Text; obj.Phone = txtPhone.Text; obj.Fax = txtFax.Text; obj.IDLocation = Convert.ToInt64((cboLocation.SelectedItem as clsComboItem).Value); ds = BranchOfficeDAO.BranchOffice_InsUpd(obj); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0 && Convert.ToInt32(ds.Tables[0].Rows[0]["Result"]) == 1) { clsMessages.ShowInformation("Cập nhật thành công!"); LoadDataToForm(); } else { clsMessages.ShowWarning("Cập nhật thất bại!"); } } catch (Exception ex) { clsMessages.ShowErrorException(ex); } finally { ds.Dispose(); } }
public IActionResult CreateOffice([FromBody] BranchOfficeDTO office) { if (office == null) { return(BadRequest()); } var cityId = office.CityId; if (!_branchOfficeService.CityExists(cityId)) { return(NotFound()); } if (_branchOfficeService.OfficeExistsByCityId(cityId)) { return(BadRequest()); } else { var newOffice = _branchOfficeService.Create(office); return(Ok(newOffice)); } }
/// <summary> /// Metodo para crear una oficina /// </summary> /// <param name="office">La oficina a crear.</param> /// <returns>Devuelve la oficina creada.</returns> public BranchOfficeDTO Create(BranchOfficeDTO office) { return(_repository.CreateOffice(office)); }