// GET: CT_PhieuXuat/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CT_PhieuXuat cT_PhieuXuat = db.CT_PhieuXuat.Find(id); if (cT_PhieuXuat == null) { return(HttpNotFound()); } ViewBag.MaPhieu = new SelectList(db.PhieuXuats, "MaPhieu", "NguoiNhan", cT_PhieuXuat.MaPhieu); ViewBag.MaSach = new SelectList(db.Saches, "MaSach", "TenSach", cT_PhieuXuat.MaSach); return(View(cT_PhieuXuat)); }
public bool AddData(CT_PhieuXuat ctpx) { cmd.CommandText = String.Format("Insert into CT_PhieuXuat values('{0}','{1}', '{2}') ", ctpx.MaPX, ctpx.MaSach, ctpx.SoLuong); cmd.CommandType = CommandType.Text; cmd.Connection = con.Connection; try { con.OpenConn(); cmd.ExecuteNonQuery(); return(true); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show("Error: " + ex.ToString(), "Lỗi", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); con.CloseConn(); cmd.Dispose(); return(false); } }
private void btnSuaCTPX_Click(object sender, EventArgs e) { CT_PhieuXuat ctpx = new CT_PhieuXuat(); ctpx.MaHH = cbMaHH.SelectedValue.ToString(); ctpx.SLXuat = Convert.ToInt32(txtSoLuongXuat.Text); ctpx.DonGiaXuat = Convert.ToInt32(txtDonGiaXuat.Text); bool b = Issue.SuaCTPhieuXuat(txtSoPX.Text, ctpx); if (b) { MessageBox.Show("Sửa thành công!"); } else { MessageBox.Show("Sửa không thành công", "Thông báo"); } dgvCTPhieuXuat.DataSource = Issue.LayChiTietPhieuXuat(txtSoPX.Text); }
public bool ThemMoiChiTietPhieuXuat(CT_PhieuXuat cT_PphieuXuat) { try { OpenDataBase(); SqlCommand sqlCommand = new SqlCommand(); List <CT_PhieuXuat> DanhSach = new List <CT_PhieuXuat>(); sqlCommand.CommandType = System.Data.CommandType.StoredProcedure; sqlCommand.CommandText = "ThemMoiThongTinPhieuXuat"; sqlCommand.Parameters.Add("@MaPhieuXuat", SqlDbType.Char).Value = cT_PphieuXuat.MaPhieuXuat; sqlCommand.Parameters.Add("@MaSanPham", SqlDbType.Char).Value = cT_PphieuXuat.MaSanPham; sqlCommand.Parameters.Add("@SoLuong", SqlDbType.Int).Value = cT_PphieuXuat.SoLuong; sqlCommand.Parameters.Add("@TongTien", SqlDbType.Money).Value = cT_PphieuXuat.TongTien; sqlCommand.Parameters.Add("@GiaKhuyenMai", SqlDbType.Money).Value = 0; sqlCommand.Parameters.Add("@GhiChu", SqlDbType.Char).Value = " "; sqlCommand.Connection = sqlConnection; int k = sqlCommand.ExecuteNonQuery(); return(k > 0); } catch (Exception ex) { throw ex; } }
public int ThemCTPhieuXuat(CT_PhieuXuat ctpx) { return(xl_ctpx.ThemCTPhieuXuat(ctpx)); }
private void BtnLuu_Click(object sender, EventArgs e) { if (gvPhieuXuat.Rows.Count <= 1) { MessageBox.Show("Dữ liệu trống, không thể lưu"); } else if (lkueMaKH.EditValue == null) { MessageBox.Show("Vui lòng chọn Khách Hàng"); } else { bool CanInsert = true; PhieuXuat px = new PhieuXuat(); px.MaPhieu = txtMaPhieu.Text; px.MaKH = lkueMaKH.EditValue.ToString(); px.NgayLap = DateTime.Parse(deNgayLap.EditValue.ToString()); px.GhiChu = rtxtGhiChu.Text; px.SoHoaDonVAT = txtSoHDVAT.Text; px.MaNVLap = lkueMaNV.EditValue.ToString(); px.SoPhieuNhapTay = txtSoPhieuNhapTay.Text; px.MaKhoXuat = lkueKho.EditValue.ToString(); px.DieuKhoanThanhToan = cbDKTT.Text; px.HinhThucThanhToan = cbHTTT.Text; px.HanThanhToan = DateTime.Parse(deHanThanhToan.EditValue.ToString()); px.NgayGiao = DateTime.Parse(deNgayGiao.EditValue.ToString()); px.DaTra = 0; px.TongTien = int.Parse(nmrThanhTien.Value.ToString()); List <CT_PhieuXuat> lstCT_PX = new List <CT_PhieuXuat>(); for (int i = 0; i < gvPhieuXuat.Rows.Count - 1; i++) { CT_PhieuXuat ctpx = new CT_PhieuXuat(); ctpx.MaPhieuXuat = px.MaPhieu; ctpx.MaHang = gvPhieuXuat.Rows[i].Cells["colMaHang"].Value.ToString(); ctpx.SoLuong = int.Parse(gvPhieuXuat.Rows[i].Cells["colSoLuong"].Value.ToString()); ctpx.DonGia = int.Parse(gvPhieuXuat.Rows[i].Cells["colDonGia"].Value.ToString()); ctpx.ThanhTien = int.Parse(gvPhieuXuat.Rows[i].Cells["colThanhTien"].Value.ToString()); //chiếu khấu lưu theo số phần trăm ctpx.ChietKhau = int.Parse(gvPhieuXuat.Rows[i].Cells["colCK"].Value.ToString()); ctpx.ThanhToan = int.Parse(gvPhieuXuat.Rows[i].Cells["colThanhToan"].Value.ToString()); int slton = int.Parse(gvPhieuXuat.Rows[i].Cells["colSLTon"].Value.ToString()); int tonSau = slton - int.Parse(gvPhieuXuat.Rows[i].Cells["colSoLuong"].Value.ToString()); if (tonSau < 0) { string tenHang = gvPhieuXuat.Rows[i].Cells["colTenHang"].FormattedValue.ToString(); DialogResult dr = MessageBox.Show(string.Format("Mặt hàng '{0}' đã xuất quá số lượng tồn\nSố lượng tồn hiện tại là {1}\nNếu thực hiện sẽ dẫn đến tồn kho bị âm\nBạn có chắc chắn muốn thực hiện công việc này không ?", tenHang, slton), "Cảnh Báo", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dr == DialogResult.Yes) { lstCT_PX.Add(ctpx); } else { CanInsert = false; break; } } else { lstCT_PX.Add(ctpx); } } if (CanInsert == true) { nv_px.ThemPhieuXuat(px); foreach (CT_PhieuXuat ct in lstCT_PX) { nv_ctpx.ThemCTPhieuXuat(ct); nv_hh.CapNhatSlTon(ct.MaHang, ct.SoLuong, 0); } AddNhatKy("Thêm", TenChucNang); MessageBox.Show("Thêm thành công"); } if (cbInSauKhiLuu.Checked) { //print preview AddNhatKy("In", TenChucNang); PrintPreview(); } } }
public bool ThemMoiChiTietPhieuXuat(CT_PhieuXuat CT_PphieuXuat) { return(hienThiCT_PhieuXuatDAL.ThemMoiChiTietPhieuXuat(CT_PphieuXuat)); }