public static int add(DaiLy daily) { try { using (EntitiesDataContext db = new EntitiesDataContext()) { DAILY dl; dl = (from d in db.DAILies where d.masodaily.Equals(daily.MaSoDaiLy) select d).SingleOrDefault(); if (dl != null) return 0; //Nếu đại lý đã tồn tại dl = new DAILY() { ten = daily.TenDaiLy, diachi = daily.DiaChi, sodienthoai = daily.SoDienThoai, sotaikhoan = daily.SoTaiKhoan, nganhang = daily.NganHang, masonguoidung = daily.MaSoNguoiDung }; db.DAILies.InsertOnSubmit(dl); db.SubmitChanges(); return dl.masodaily; } } catch(Exception ex) { Console.WriteLine(ex.Message); return 0; } }
public ActionResult Create(DaiLy model) { try { // TODO: Add insert logic here if (ModelState.IsValid) { var result = DaiLyManager.add(model); if (result != 0) { putSuccessMessage("Thâm thành công"); return RedirectToAction("Details", new { id = result }); } else { putErrorMessage("Thêm thất bại"); } } else { putModelStateFailErrors(ModelState); } return View(model); } catch(Exception ex) { putErrorMessage(ex.Message); return RedirectToAction("Create"); } }
public static bool edit(DaiLy daily) { try { using(EntitiesDataContext db = new EntitiesDataContext()) { DAILY dl; dl = (from d in db.DAILies where d.masodaily.Equals(daily.MaSoDaiLy) select d).SingleOrDefault(); if (dl == null) return false; //Nếu đại lý không tồn tại dl.ten = daily.TenDaiLy; dl.diachi = daily.DiaChi; dl.sodienthoai = daily.SoDienThoai; dl.sotaikhoan = daily.SoTaiKhoan; dl.trangthai = daily.TrangThai; dl.nganhang = daily.NganHang; db.SubmitChanges(); return true; } }catch(Exception ex) { Console.WriteLine(ex.Message); return false; } }
//Khi thêm Đại lý private void btnThem_Click(object sender, EventArgs e) { DialogResult dialogResult = MessageBox.Show("Bạn có muốn thêm đại lý", "Thông báo", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { if (!txbTenDaiLy.Text.Equals("") && !txbDiaChi.Text.Equals("") && !txbSoDienThoai.Text.Equals("") && !txbSoTaiKhoan.Text.Equals("")) { DaiLy dl = new DaiLy(); dl.TenDaiLy = txbTenDaiLy.Text; dl.DiaChi = txbDiaChi.Text; dl.SoDienThoai = txbSoDienThoai.Text; dl.SoTaiKhoan = txbSoTaiKhoan.Text; dl.NganHang = txbNganHang.Text.ToString(); if (DaiLyManager.add(dl) != 0) MessageBox.Show("Đã thêm đại lý thành công"); else MessageBox.Show("Không thêm được, đại lý đã tồn tại "); } else MessageBox.Show("Bạn chưa nhập đầy đủ thông tin"); } else if (dialogResult == DialogResult.No) { return; } }
public void selectDaiLy(DaiLy daily) { if (daily != null) { lbMaSoDaiLy.Text = daily.MaSoDaiLy.ToString(); lbTenDaiLy.Text = daily.TenDaiLy; lbTienSachDaiLy.Text = String.Format(_cultureInfo, "{0:c}", daily.TongTienXuatTheoThang); lbConNoDaiLy.Text = String.Format(_cultureInfo, "{0:c}", daily.TongTienNoThang); lbDaThuDaiLy.Text = String.Format(_cultureInfo, "{0:c}", daily.TongTienXuatTheoThang - daily.TongTienNoThang); } }
public void selectDaiLy(DaiLy daily) { if (daily != null) { txbMaSoDaiLy.Text = daily.MaSoDaiLy.ToString(); txbTenDaiLy.Text = daily.TenDaiLy; txbDiaChi.Text = daily.DiaChi; txbSoDienThoai.Text = daily.SoDienThoai; txbSoTaiKhoan.Text = daily.SoTaiKhoan; txbNganHang.Text = daily.NganHang; } }
public frmChiTietCongNoDaiLy(Form parent,DaiLy daily) : this(parent) { this._daily = daily; }
public HoaDonDaiLy(HOADONDAILY hoadon, DAILY daily) : this(hoadon) { DaiLy = new DaiLy(daily); }
public NguoiDung(NGUOIDUNG nd, DAILY dl) : this(nd) { MaSoDaiLy = dl.masodaily; DaiLy = new DaiLy(dl); }
public CongNoDaiLy(CONGNODAILY congno, DAILY daily) : this(congno) { DaiLy = new DaiLy(daily); }
private void gdvDaiLy_SelectionChanged(object sender, EventArgs e) { int index = gdvDaiLy.CurrentRow.Index; _CurrentDaiLy = (gdvDaiLy.DataSource as List<DaiLy>)[index]; }
public ActionResult Edit(DaiLy model, FormCollection collection) { try { // TODO: Add update logic here if (ModelState.IsValid) { if (DaiLyManager.edit(model)) { putSuccessMessage("Cập nhật thành công"); return RedirectToAction("Details", new { id = model.MaSoDaiLy }); } else { putErrorMessage("Cập nhật thất bại"); } } else { putModelStateFailErrors(ModelState); } return View(model); } catch(Exception ex) { putErrorMessage(ex.Message); return RedirectToAction("Edit", new { id = model.MaSoDaiLy }); } }
public PhieuXuat(PHIEUXUAT phieu, DAILY daily) : this(phieu) { Daily = new DaiLy(daily); }
//Khi chọn công nợ của 1 đại lý private void gdvDMCongNo_SelectionChanged(object sender, EventArgs e) { int index = ((DataGridView)sender).CurrentRow.Index; _currentDaiLy = (((DataGridView)sender).DataSource as List<DaiLy>)[index]; selectDaiLy(_currentDaiLy); }
public frmThongKeNguonThu(Form parent, DaiLy dl) : this(parent) { _CurrentDaiLy = dl; }
public frmThanhToanDaiLy(Form parent, DaiLy daily) : this(parent) { _currentDaiLy = daily; }
private void cmbDaiLy_SelectionChangeCommitted(object sender, EventArgs e) { _currentDaiLy = DaiLyManager.find(int.Parse(cmbDaiLy.SelectedValue.ToString())); txbMaSoDaiLy.Text = _currentDaiLy.MaSoDaiLy + ""; loadSach(); cmbDaiLy.Enabled = false; }
// GET: DaiLy/Create public ActionResult Create() { var model = new DaiLy(); setAlertMessage(); return View(model); }
public ActionResult UpdateAgency(DaiLy model, FormCollection collection) { var errors = new List<string>(); if (ModelState.IsValid) { var currentUser = Session[Core.Constants.SESSION.USERNAME] as NguoiDung; model.MaSoNguoiDung = currentUser.MaSoNguoiDung; if (currentUser.DaiLy == null) { var result = DaiLyManager.add(model); if(result != 0) { model.MaSoDaiLy = result; currentUser.DaiLy = model; currentUser.MaSoDaiLy = result; Session[Core.Constants.SESSION.USERNAME] = currentUser; TempData[Core.Constants.TEMPDATA.SUCCESS] = new List<string> { "Đăng ký đại lý thành công" }; } else { errors.Add("Đăng ký không thành công"); TempData[Core.Constants.TEMPDATA.ERRORS] = errors; } } else { if (DaiLyManager.edit(model)) { currentUser.DaiLy = model; Session[Core.Constants.SESSION.USERNAME] = currentUser; TempData[Core.Constants.TEMPDATA.SUCCESS] = new List<string> { "Cập nhật thành công" }; } else { errors.Add("Cập nhật không thành công"); TempData[Core.Constants.TEMPDATA.ERRORS] = errors; } } if (errors.Count > 0) { TempData[Core.Constants.TEMPDATA.ERRORS] = errors; } return RedirectToAction("Agency"); } else { foreach (var value in ModelState.Values) { if (value.Errors.Count > 0) { foreach (var error in value.Errors) { errors.Add(error.ErrorMessage); } } } TempData[Core.Constants.TEMPDATA.ERRORS] = errors; return RedirectToAction("Agency"); } }