public async Task <IActionResult> Put(int id, Bussiness newValues) { try { var bussiness = await db.Bussinesses.Get(id); if (bussiness == null) { return(NotFound()); } bussiness.Name = newValues.Name; bussiness.Description = newValues.Description; bussiness.PhoneNumber = newValues.PhoneNumber; await db.Complete(); return(Created(HttpContext.Request.Path, bussiness)); } catch (Exception ex) { return(BadRequest(new { Message = $"No se ha podido modificar la empresa con id: {id}", Exception = ex.InnerException?.Message ?? ex.Message })); } }
protected void btnSave_Click(object sender, EventArgs e) { if (hfPopupUpdate.Value == "0") { if (obj.InsertCauHInh(LayDonVi())) { ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "alertMessage('Thành công!','success','Thêm mới thành công!!');", true); LoadDonVi(); cleartext(); } else { ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "alertMessage('Cảnh báo!','warning','Lỗi khi thêm mới. vui lòng kiểm tra lại dữ liệu..!!');", true); } } else { if (Bussiness.UpdateCauHinh(LayDonVi(), int.Parse(hfPopupUpdate.Value))) { ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "alertMessage('Thành công!','success','Cập nhật cấu hình thành công !');", true); LoadDonVi(); } else { ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "alertMessage('Cảnh báo!','warning','Có lỗi khi cập nhật cấu hình !');", true); } } }
private void Update_Click(object sender, EventArgs e) { if (id.Text == "" || (name.Text == "") || address.Text == "" || age.Text == "" || contactNo.Text == "" || noOfHours.Text == "" || type.Text == "") { MessageBox.Show("Please Fill All Textboxes"); } else { try { Bussiness bs = new Bussiness(); Employee emp = new Employee(); emp.employeeId = Convert.ToInt32(id.Text); emp.employeeName = name.Text; emp.employeeAddress = address.Text; emp.employeeAge = Convert.ToInt32(age.Text); emp.employeeContactNumber = Convert.ToInt32(contactNo.Text); emp.employeeNoOfHours = Convert.ToInt32(noOfHours.Text); emp.employeeType = type.Text; bs.update_details(emp); MessageBox.Show("Successfully Updated"); } catch (Exception ex) { MessageBox.Show("Error in Update"); } } }
protected void btnSave_Click(object sender, EventArgs e) { if (!lbnhomid.Text.Trim().Equals("")) { try { int id = int.Parse(lbnhomid.Text.Trim()); if (KiemTraDuLieu().Equals("ok")) { if (Bussiness.UpdateDV(LayDonVi(), id)) { //lbThongbao.Text = "Đã cập nhật thông tin thành công!!"; ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "alertMessage('Thành công!','success','Đã cập nhật thông tin thành công!!');", true); } } } catch (Exception ex) { throw ex; } } else { //lbThongbao.Text = "Vui lòng chọn dử liệu để sửa"; ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "alertMessage('Thành công!','success','Vui lòng chọn dử liệu để sửa');", true); } }
protected void btnXoadongy_Click(object sender, EventArgs e) { try { int id = int.Parse(hfPopupDelete.Value); int iddoanhnghiep = int.Parse(AppSessionInfo.CurrentUser.DoanhNghiepID.ToString()); if (Bussiness.CheckExistKH(id, iddoanhnghiep)) { ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "alertMessage('Cảnh báo!','warning','Còn tồn tại nhân viên trong nhóm !');", true); } else { if (Bussiness.DeleteNhomKH(id, iddoanhnghiep)) { ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "alertMessage('Thành công!','success','Xóa nhóm khách hàng thành công!!');", true); LoadDonVi(); cleartext(); } else { ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "alertMessage('Cảnh báo!','warning','Có lỗi khi xóa!!');", true); } } } catch (Exception ex) { throw ex; } }
protected void btnXuatBCNT_Click(object sender, EventArgs e) { int doanhnghiepid = 0; if (AppSessionInfo.CurrentUser.DoanhNghiepID != null) { if (!AppSessionInfo.CurrentUser.DoanhNghiepID.ToString().Equals("")) { doanhnghiepid = int.Parse(AppSessionInfo.CurrentUser.DoanhNghiepID.ToString()); } } else { Response.Redirect(AppUrls.LOGIN); } string ngaybd = "", ngaykt = ""; if (txtNgayBD.Text.Trim().Length == 10 && txtNgayKT.Text.Trim().Length == 10) { ngaybd = ChuyenNgay(txtNgayBD.Text); ngaykt = ChuyenNgay(txtNgayKT.Text); DataTable dt = Bussiness.GetBaoCaoNT(ngaybd, ngaykt, doanhnghiepid).Tables["nhantin"]; ExportToExcel(dt); //DataSet ds1 = Bussiness.GetTimKiemTheoNgayXuat("15/09/2016", 1); //ExportToExcelKH(ds1.Tables[0]); } else { ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "alertMessage('Cảnh báo!','warning','Nhập ngày không đúng định dạng..!!');", true); } }
public void TestCaseForImplementedMethod() { var mock = new Mock <Repository>(); Bussiness bussiness = new Bussiness(mock.Object); Assert.AreEqual(4, bussiness.Addition(2, 2)); }
protected void btnExportToExxcel_ServerClick(object sender, EventArgs e) { string path = string.Concat(Server.MapPath("~/Upload/NhanTin/" + FileUpload1.FileName)); if (!FileUpload1.FileName.Equals("")) { string sl = "0"; FileUpload1.SaveAs(path); List <Donvi> lsdv = obj.GetDonVi(true); if (lsdv != null) { if (lsdv.Count > 0) { DataTable dt = Bussiness.NhanTinExcel(path, Doanhnghiepid, 1, lsdv[0].AGENTID.Trim(), lsdv[0].APIUSER.Trim(), lsdv[0].APIPASS.Trim()); ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "alertMessage('Thành công!','success','Đã nhắn tin vui lòng kiểm tra file trả về để xem lỗi nếu có.!');", true); // LoadGrid(0); if (dt.Rows.Count > 1) { ExportToExcel(dt); } } } } else { ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "alertMessage('Cảnh báo!','warning','Vui lòng chọn file để nhắn tin!!');", true); } LoadGrid(0, 1000, "NhanTinExcel"); }
protected void btnUSave_Click(object sender, EventArgs e) { if (hfPopupUpdate.Value == "0") { if (Bussiness.InsertDN(LayNoiDung())) { ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "alertMessage('Thành công!','success','Thêm mới thành công!!');", true); LoadUserGroup(0); Cleartext(); } else { ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "alertMessage('Cảnh báo!','warning','Lỗi khi thêm mới. vui lòng kiểm tra lại dữ liệu..!!');", true); } } else { if (Bussiness.UpdateDN(LayNoiDung(), int.Parse(hfPopupUpdate.Value))) { ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "alertMessage('Thành công!','success','Cập nhật doanh nghiệp thành công !');", true); LoadUserGroup(0); } else { ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "alertMessage('Cảnh báo!','warning','Có lỗi khi cập nhật doanh nghiệp !');", true); } } }
public async Task <Bussiness> AddBussiness(Bussiness bussiness) { await _context.bussinesses.AddAsync(bussiness); await _context.SaveChangesAsync(); return(bussiness); }
public void TestCaseForNotImplementedMethods() { var mock = new Mock <Repository>(); mock.Setup(self => self.Sub(3, 2)).Returns(3); Bussiness bussiness = new Bussiness(mock.Object); Assert.AreEqual(3, bussiness.Substraction(3, 2)); }
public bool Insert(Bussiness bussiness) { try { _bussinesss.Add(bussiness); return(true); } catch (Exception) { return(false); } }
public static void Call() { try { Bussiness.Call(); } catch (Exception ex) { Console.WriteLine("Log:"); Console.WriteLine(ex); throw; } }
protected void btnXoadongy_Click(object sender, EventArgs e) { if (Bussiness.DeleteDN(int.Parse(hfPopupDelete.Value))) { ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "alertMessage('Thành công!','success','Xóa doanh nghiệp thành công !');", true); LoadUserGroup(0); // Cleartext(); } else { ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "alertMessage('Cảnh báo!','warning','Có lỗi khi xóa doanh nghiệp !');", true); } }
public bool Delete(Bussiness bussiness) { try { _bussinesss.Attach(bussiness); _bussinesss.Remove(bussiness); return(true); } catch (Exception) { return(false); } }
public async Task <IActionResult> registerbussiness([FromBody] Bussiness bussiness) { try{ if (await _bussiness.BussinessExist(bussiness.Phonenumber)) { return(BadRequest("Bussiness Already Exist")); } var BussinessCreated = await _bussiness.AddBussiness(bussiness); return(StatusCode(201)); } catch { return(StatusCode(500, "computer says no")); } }
private void Delete_Click(object sender, EventArgs e) { try { Bussiness bs = new Bussiness(); Employee emp = new Employee(); int ID = Convert.ToInt32(id.Text); bs.delete_details(ID); MessageBox.Show("Successfully Deleted"); } catch (Exception ex) { MessageBox.Show("Error in Delete"); } }
public IHttpActionResult Get(int id) { try { Bussiness u = BussinessDB.GetBussinessByID(id); if (u != null) { return(Ok(u)); } return(Content(HttpStatusCode.NotFound, $"bussiness witn id {id} was not found!!!")); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
protected void btnExportToExxcel_ServerClick(object sender, EventArgs e) { string path = string.Concat(Server.MapPath("~/Upload/" + FileUpload1.FileName)); if (!IsAdmin()) { if (!path.Equals("")) { string sl = "0"; FileUpload1.SaveAs(path); DataTable dt = Bussiness.uploadexcel(path, int.Parse(AppSessionInfo.CurrentUser.DoanhNghiepID.ToString())); if (dt.Rows.Count > 0) { if (dt.Rows.Count == 1) { sl = dt.Rows[0]["count"].ToString(); } else { if (int.Parse(dt.Rows[0]["count"].ToString()) < 2) { sl = "0"; } else if (int.Parse(dt.Rows[0]["count"].ToString()) > dt.Rows.Count) { sl = (int.Parse(dt.Rows[0]["count"].ToString()) - dt.Rows.Count - 1).ToString(); } else { sl = (int.Parse(dt.Rows[0]["count"].ToString()) - dt.Rows.Count).ToString(); } } } ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "alertMessage('Thành công!','success','Đã thêm mới " + sl + " dòng !');", true); LoadGrid(0); if (dt.Rows.Count != 1) { ExportToExcel(dt); } } } }
protected void btnUSave_Click(object sender, EventArgs e) { if (hfPopupUpdate.Value == "0") { try { if (Bussiness.cHECKKhachHang_ExcludeDoanhNghiep(txtdienthoai.Text.Trim(), txtkhungxe.Text.Trim(), int.Parse(AppSessionInfo.CurrentUser.DoanhNghiepID.ToString()))) { if (Bussiness.InsertKH(LayKhachHangNew())) { ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "alertMessage('Thành công!','success','Nhập mới khách hàng thành công !');", true); LoadGrid(0); clearText(); } else { ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "alertMessage('Cảnh báo!','warning','Có lỗi khi nhập mới, vui lòng xem lại nội dung!');", true); } } else { ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "alertMessage('Cảnh báo!','warning','Lỗi trùng số khung và số điện thoại khách hàng!');", true); } } catch (Exception ex) { throw ex; } } else { if (Bussiness.cHECKKhachHang(txtdienthoai.Text.Trim(), txtkhungxe.Text.Trim(), int.Parse(hfPopupUpdate.Value))) { if (Bussiness.UpdateKH(LayKhachHang(), int.Parse(hfPopupUpdate.Value))) { ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "alertMessage('Thành công!','success','Đã sửa đổi thành công !');", true); LoadGrid(tranghientai); } } else { ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "alertMessage('Cảnh báo!','warning','Đã tồn tài số khung và số điện thoại khách hàng!');", true); } } }
protected void btnXoadongy_Click(object sender, EventArgs e) { try { int id = int.Parse(hfPopupDelete.Value); if (Bussiness.DeleteKH(id)) { ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "alertMessage('Thành công!','success','Đã xóa thành công !');", true); LoadGrid(tranghientai); Reset(); } } catch (Exception ex) { throw ex; } }
public async Task <IActionResult> Post(Bussiness bussiness) { try { await db.Bussinesses.Add(bussiness); await db.Complete(); return(Created(HttpContext.Request.Path, bussiness)); } catch (Exception ex) { return(BadRequest(new { Message = "No se ha podido agregar la empresa", Exception = ex.InnerException?.Message ?? ex.Message })); } }
public async Task <Bussiness> AddBussinessAsync(string code, string name, string address, string phoneNumber, string email, string owner, string ownerPhone, string userId) { var bussines = new Bussiness { Code = code, Name = name, Address = address, PhoneNumber = phoneNumber, Email = email, Owner = owner, OwnerPhone = ownerPhone, UserId = userId }; await _dbContext.AddAsync(bussines); await _dbContext.SaveChangesAsync(); return(bussines); }
private void searchbtn_Click(object sender, EventArgs e) { try { Bussiness bs = new Bussiness(); Employee emp = new Employee(); DataSet ds = new DataSet(); ds = bs.read_details(Convert.ToInt32(id.Text)); name.Text = ds.Tables[0].Rows[0]["Name"].ToString(); address.Text = ds.Tables[0].Rows[0]["Address"].ToString(); age.Text = ds.Tables[0].Rows[0]["Age"].ToString(); contactNo.Text = ds.Tables[0].Rows[0]["ContactNumber"].ToString(); noOfHours.Text = ds.Tables[0].Rows[0]["NoOfHours"].ToString(); type.Text = ds.Tables[0].Rows[0]["EmpType"].ToString(); } catch (Exception ex) { MessageBox.Show("invalid Search"); } }
public IHttpActionResult Put([FromBody] Bussiness bussiness2Update) { try { Bussiness u = BussinessDB.GetBussinessByID(bussiness2Update.Bussiness_Id); if (u != null) { int res = BussinessDB.UpdateBussiness(bussiness2Update); if (res == 1) { return(Ok($"bussiness with id = {bussiness2Update.Bussiness_Id} updated")); } return(Content(HttpStatusCode.NotModified, $"bussiness with id = {bussiness2Update.Bussiness_Id} exsits but could not be modified!!!")); } return(Content(HttpStatusCode.NotFound, $"bussiness with id = {bussiness2Update.Bussiness_Id} was not found to update!!!")); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public IHttpActionResult Post([FromBody] Bussiness bussiness2Insert) { try { User u = UsersDB.GetUserByEmail(bussiness2Insert.userEmail); if (u != null) { int res = BussinessDB.InsertBussiness(bussiness2Insert); if (res == -1) { return(Content(HttpStatusCode.BadRequest, $"bussiness with id = {bussiness2Insert.Bussiness_Id} was not created in DB!!!")); } bussiness2Insert.Bussiness_Id = res; return(Created(new Uri(Request.RequestUri.AbsoluteUri + res), bussiness2Insert)); } return(Content(HttpStatusCode.BadRequest, $"user not exist")); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public bool Update(Bussiness bussiness) { try { var local = _uow.Set <Bussiness>() .Local .FirstOrDefault(f => f.ID == bussiness.ID); if (local != null) { _uow.Entry(local).State = EntityState.Detached; } _bussinesss.Attach(bussiness); _uow.Entry(bussiness).State = EntityState.Modified; return(true); } catch (Exception ex) { return(false); } }
private void CalculateSalary_Click(object sender, EventArgs e) { try { Bussiness bs = new Bussiness(); if (type.Text == "Internal") { InternalEmployee emp = new InternalEmployee(); float otPayment = emp.CalcOverTimePayment(Convert.ToInt32(noOfHours.Text), float.Parse(otHourRate.Text)); salary.Text = (emp.CalcNetSalary(float.Parse(basicSal.Text), otPayment)).ToString(); } else if (type.Text == "External") { ExternalEmployee exEmp = new ExternalEmployee(); salary.Text = (exEmp.CalcNetSalary(float.Parse(otHourRate.Text), Convert.ToInt32(noOfHours.Text))).ToString(); } } catch (Exception ex) { MessageBox.Show("invalid calculation"); } }
protected void btnExportAllKH_ServerClick(object sender, EventArgs e) { //string filename = "DSKhachHang_" + DateTime.Now.Year.ToString(); //string sPathMau = Server.MapPath("fileExcelMau\\"); //string sPath = Server.MapPath("fileExport\\"); //if (!Directory.Exists(sPath)) // CHECK IF THE FOLDER EXISTS. IF NOT, CREATE A NEW FOLDER. //{ // Directory.CreateDirectory(sPath); //} //Excel.Application xlAppToExport = new Excel.Application(); //Excel.Workbook wb = xlAppToExport.Workbooks.Open(sPathMau + "FileMauKH.xlsx"); //Excel.Worksheet xlWorkSheetToExport = default(Excel.Worksheet); //xlWorkSheetToExport = (Excel.Worksheet)xlAppToExport.Sheets["Sheet1"]; //File.Delete(sPath + "" + filename + ".xlsx"); // DELETE THE FILE BEFORE CREATING A NEW ONE. // // ADD A WORKBOOK USING THE EXCEL APPLICATION. //List<KhachHang> lskh = null; //lskh = obj.GetKhachHang(true); //int iRowCnt = 7; //for (int i = 0; i < 500; i++) //{ // xlWorkSheetToExport.Cells[iRowCnt, 1] = lskh[i].ID.ToString(); // xlWorkSheetToExport.Cells[iRowCnt, 2] = lskh[i].TenKhachHang.ToString(); // xlWorkSheetToExport.Cells[iRowCnt, 3] = lskh[i].DienThoai.ToString(); // xlWorkSheetToExport.Cells[iRowCnt, 4] = lskh[i].Ngaysinh.ToString(); // xlWorkSheetToExport.Cells[iRowCnt, 5] = lskh[i].DoanhNghiepID.ToString(); // xlWorkSheetToExport.Cells[iRowCnt, 6] = lskh[i].GhiChu.ToString(); // xlWorkSheetToExport.Cells[iRowCnt, 7] = lskh[i].HoatDong.ToString(); // xlWorkSheetToExport.Cells[iRowCnt, 8] = lskh[i].NgayMuaXe.ToString(); // xlWorkSheetToExport.Cells[iRowCnt, 9] = lskh[i].Lan1.ToString(); // xlWorkSheetToExport.Cells[iRowCnt, 10] = lskh[i].Lan2.ToString(); // xlWorkSheetToExport.Cells[iRowCnt, 11] = lskh[i].Lan3.ToString(); // xlWorkSheetToExport.Cells[iRowCnt, 12] = lskh[i].Lan4.ToString(); // xlWorkSheetToExport.Cells[iRowCnt, 13] = lskh[i].Lan5.ToString(); // xlWorkSheetToExport.Cells[iRowCnt, 14] = lskh[i].Lan6.ToString(); // xlWorkSheetToExport.Cells[iRowCnt, 15] = lskh[i].nhanxe.ToString(); // xlWorkSheetToExport.Cells[iRowCnt, 16] = lskh[i].IDNhom.ToString(); // xlWorkSheetToExport.Cells[iRowCnt, 17] = lskh[i].NhanTinSN.ToString(); // xlWorkSheetToExport.Cells[iRowCnt, 18] = lskh[i].KhungXe.ToString(); // xlWorkSheetToExport.Cells[iRowCnt, 19] = "1"; // iRowCnt = iRowCnt + 1; //} //xlWorkSheetToExport.SaveAs(sPath + "" + filename + ".xlsx"); //ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "alertMessage('Thành công!','success','Xuất dữ liệu thành công!');", true); //// CLEAR. //wb.Close(true, sPathMau + "FileMauKH.xlsx", Missing.Value); //xlAppToExport.Quit(); //KillExcel(xlAppToExport); //xlAppToExport = null; //xlWorkSheetToExport = null; //Response.AppendHeader("Content-Disposition", "attachment; filename="+ filename + ".xlsx"); //Response.TransmitFile(sPath + "" + filename + ".xlsx"); //Response.End(); int doanhnghiepid = 0; if (AppSessionInfo.CurrentUser.DoanhNghiepID != null) { if (!AppSessionInfo.CurrentUser.DoanhNghiepID.ToString().Equals("")) { doanhnghiepid = int.Parse(AppSessionInfo.CurrentUser.DoanhNghiepID.ToString()); } } else { Response.Redirect(AppUrls.LOGIN); } DataSet ds = Bussiness.GetTimKiem("", doanhnghiepid); ExportToExcelKH(ds.Tables[0]); }
public bool InsertPerson(Bussiness.PersonEntity person) { return _personBLL.InsertPerson(person); }
public async Task <IEnumerable <Bussiness> > GetAll() { var bussiness = new Bussiness(); return(await _context.bussinesses.ToListAsync()); }
/// <summary> /// 替换审核者、设计者、日期等属性 /// </summary> /// <param name="entity"></param> public static void ReplaceProperty(AcadEntity entity, AcadBlocks blocks, Bussiness.Rules rules) { if (entity.ObjectName == "AcDbBlockReference") { var s = ((AcadBlockReference)entity); var name = blocks.Item(s.Name).Name; blocks.Item(s.Name).Name = rand.Next().ToString(); if (s.HasAttributes) { AcadAttributeReference bb; object[] aa = (object[])s.GetAttributes(); for (int i = 0; i < aa.Length; i++) { bb = aa[i] as AcadAttributeReference; if (bb != null) { if (bb.TagString != "---------" && bb.TagString != "------" && !bb.TagString.Contains("GEN-TITLE-MAT") && !bb.TagString.Contains("GEN-TITLE-DES") && bb.TagString != "01" && !bb.TagString.Contains("GEN-TITLE-SCA{6.14,1}")) { bb.TextString = ""; } if (bb.TagString == "---------") { oldCode = bb.TextString; oldCode = ReplaceStr(oldCode); var startCode = oldCode.Substring(0, RegexCode()); var endCode = oldCode.Substring(RegexCode(), oldCode.Length - RegexCode()); Hashtable hash = rules.GetRules(); foreach (DictionaryEntry de in hash) { if (startCode == de.Key.ToString()) { startCode = de.Value.ToString(); } } newCode = startCode + "0" + Rand(); if (!string.IsNullOrEmpty(newCode)) bb.TextString = newCode; } } } } } else if (entity.ObjectName == "AcDbMText") { AcadMText mtext = entity as AcadMText; if (mtext != null) { if (mtext.TextString.Contains("FAX") || mtext.TextString.Contains("TEL") || mtext.TextString.Contains("TOMITA")) { mtext.TextString = ""; } } } }