public static bool ThemChiTietMuaHang(pdna1 chitiet) { try { db.pdna1s.InsertOnSubmit(chitiet); db.SubmitChanges(); return(true); } catch (Exception) { throw; } }
public static bool XoaPhieuMuaHang(string pdno, string gsbh, string CLBH, string size) { try { pdna1 phieu = db.pdna1s.Where(p => p.GSBH == gsbh && p.pdNO == pdno && p.CLBH == CLBH && p.Size == size).SingleOrDefault(); db.pdna1s.DeleteOnSubmit(phieu); db.SubmitChanges(); return(true); } catch (Exception) { throw; } }
public static bool SuaChiTietPhieuMuaHang(pdna1 chitiet) { try { pdna1 phieu = db.pdna1s.Where(p => p.GSBH == chitiet.GSBH && p.pdNO == chitiet.pdNO).SingleOrDefault(); phieu.GSBH = chitiet.GSBH; phieu.pdNO = chitiet.pdNO; phieu.CLBH = chitiet.CLBH; phieu.Qty = chitiet.Qty; phieu.CLmemo = chitiet.CLmemo; phieu.Memo0 = chitiet.Memo0; db.SubmitChanges(); return(true); } catch (Exception) { throw; } }
protected void Button1_Click1(object sender, EventArgs e) { // tao phieu mua hang string ngonngu = Session["languege"].ToString(); //string dem = (pdnaBUS.DemSoLuongVanBan() + 1).ToString(); //string maphieu = DateTime.Parse(DateTime.Now.ToShortDateString()).ToString("yyyyMMdd") + "00" + dem; string maphieu = ""; dalPDN dal = new dalPDN(); DataTable dt = dal.DemSoLuongPhieu(); string aa = dt.Rows[0]["pdno"].ToString().Trim(); if (dt.Rows.Count != 0 && aa != "") { string dem = (int.Parse(aa) + 1).ToString(); maphieu = dem; } else { maphieu = DateTime.Parse(DateTime.Now.ToShortDateString()).ToString("yyyyMM") + "00" + 1; } string bophan = DropDonVi.SelectedItem.Value.ToString(); string tieude = txtTieuDe.Text; string noidung = CKEditorControl1.Text; string bp = DropDonVi.SelectedItem.Text; string loaiP = DropLoaiPhieu.SelectedItem.Text; string macongty = Session["congty"].ToString(); string user = Session["user"].ToString(); string ngaythang = DateTime.Parse(DateTime.Now.ToShortDateString()).ToString("dd/MM/yyyy"); string ngaythang1 = DateTime.Parse(DateTime.Now.ToShortDateString()).ToString("Ngày " + "dd" + "Tháng " + "MM" + "Năm" + "yyyy"); //string idphieu = Session["maphieu"].ToString(); string loaiphieu = DropLoaiPhieu.SelectedValue.ToString(); Busers2 timnguoitao = UserBUS.TimNhanVienTheoMa(user, macongty); if (timnguoitao.IDCapDuyet >= 12) { string madonvi = "CBCC"; Session["bp"] = madonvi; BDepartment bd = BDepartmentBUS.TimMaDonVi(madonvi, macongty); Busers2 us = UserBUS.TimMaNhanVienTheoBoPhan(user, madonvi, macongty); if (us == null) { Busers2 kiemtra = UserDAO.TimNhanVienQuanLyDonVi(user, madonvi, macongty); if (kiemtra == null) { if (ngonngu == "lbl_VN") { lbthongbao.Text = "Người dùng này không thuộc bộ phận " + bd.DepName; tablePMH.Visible = true; btnLuuTam.Enabled = false; btnTiepTu.Enabled = false; } else if (ngonngu == "lbl_TW") { lbthongbao.Text = "该用户不属于部门 " + bd.DepName; tablePMH.Visible = true; btnLuuTam.Enabled = false; btnTiepTu.Enabled = false; } else if (ngonngu == "lbl_EN") { lbthongbao.Text = "The user does not belong to the department" + bd.DepName; tablePMH.Visible = true; btnLuuTam.Enabled = false; btnTiepTu.Enabled = false; } } else { pdna phieun = new pdna(); { phieun.GSBH = macongty; phieun.pdno = maphieu; phieun.pddepid = bophan; phieun.mytitle = tieude; phieun.pdmemovn = noidung; phieun.CFMDate0 = DateTime.Parse(ngaythang); phieun.USERID = user; phieun.Abtype = DropLoaiPhieu.SelectedValue.ToString(); phieun.bixoa = false; phieun.CFMID0 = user; phieun.YN = 5; phieun.bixoa = false; phieun.USERDATE = DateTime.Parse(ngaythang); phieun.UseIntent = txtMucDich.Text; } db.pdnas.InsertOnSubmit(phieun); db.SubmitChanges(); string tenhang = txtTenHang.Text; //string tenhang = dropTenHang.SelectedValue; string donvitinh = txtdonvitinh.Text; string soluong = txtSoLuong.Text; string ghichu = txtGhiChu.Text; string Size = ""; if (txtSize.Text.Trim() == "") { Size = "."; } else { Size = txtSize.Text.Trim(); } pdna1 hang = new pdna1(); hang.GSBH = macongty; hang.pdNO = maphieu; db.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues, db.ExecuteQuery <BOfSupply>("select b.IDOfSupplies,b.OfSuppliesName,b.pdno,b.GSBH,b.BUnit,b.BNumber,b.BCommnent from pdna p left join BOfSupplies b on p.pdno=b.pdno and p.GSBH=b.GSBH where b.pdno='" + maphieu + "' and b.GSBH='" + macongty + "'")); //GridView1.DataSource = db.ExecuteQuery<BOfSupply>("select b.IDOfSupplies,b.OfSuppliesName,b.pdno,b.GSBH,b.BUnit,b.BNumber,b.BCommnent from pdna p left join BOfSupplies b on p.pdno=b.pdno and p.GSBH=b.GSBH where b.pdno='" + maphieu + "' and b.GSBH='" + macongty + "'"); //GridView1.DataBind(); tablePMH.Visible = false; btnLuuTam.Enabled = true; btnTiepTu.Enabled = true; } Busers2 usertao = UserBUS.TimNhanVienTheoMa(user, macongty); if (usertao != null && usertao.IDCapDuyet > 12) { Response.Redirect("FrmViewCB.aspx"); } else { if (ngonngu == "lbl_VN") { lbthongbao.Text = "Người dùng này không thuộc bộ phận " + bd.DepName; tablePMH.Visible = true; btnLuuTam.Enabled = false; btnTiepTu.Enabled = false; } else if (ngonngu == "lbl_TW") { lbthongbao.Text = "该用户不属于部门 " + bd.DepName; tablePMH.Visible = true; btnLuuTam.Enabled = false; btnTiepTu.Enabled = false; } else if (ngonngu == "lbl_EN") { lbthongbao.Text = "The user does not belong to the department" + bd.DepName; tablePMH.Visible = true; btnLuuTam.Enabled = false; btnTiepTu.Enabled = false; } } } else { pdna phieun = new pdna(); { phieun.GSBH = macongty; phieun.pdno = maphieu; phieun.pddepid = bophan; phieun.mytitle = tieude; phieun.pdmemovn = noidung; phieun.CFMDate0 = DateTime.Parse(ngaythang); phieun.USERID = user; phieun.Abtype = DropLoaiPhieu.SelectedValue.ToString(); phieun.bixoa = false; phieun.CFMID0 = user; phieun.YN = 5; phieun.bixoa = false; phieun.USERDATE = DateTime.Parse(ngaythang); phieun.UseIntent = txtMucDich.Text; } db.pdnas.InsertOnSubmit(phieun); db.SubmitChanges(); string tenhang = txtTenHang.Text; //string tenhang = dropTenHang.SelectedValue; string donvitinh = txtdonvitinh.Text; string soluong = txtSoLuong.Text; string ghichu = txtGhiChu.Text; BOfSupply hang = new BOfSupply(); hang.GSBH = macongty; hang.pdno = maphieu; hang.OfSuppliesName = tenhang; hang.BUnit = donvitinh; hang.BNumber = int.Parse(soluong); hang.BCommnent = ghichu; SuppliesDAO.ThemVatTu(hang); db.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues, db.ExecuteQuery <BOfSupply>("select b.IDOfSupplies,b.OfSuppliesName,b.pdno,b.GSBH,b.BUnit,b.BNumber,b.BCommnent from pdna p left join BOfSupplies b on p.pdno=b.pdno and p.GSBH=b.GSBH where b.pdno='" + maphieu + "' and b.GSBH='" + macongty + "'")); //GridView1.DataSource = db.ExecuteQuery<BOfSupply>("select b.IDOfSupplies,b.OfSuppliesName,b.pdno,b.GSBH,b.BUnit,b.BNumber,b.BCommnent from pdna p left join BOfSupplies b on p.pdno=b.pdno and p.GSBH=b.GSBH where b.pdno='" + maphieu + "' and b.GSBH='" + macongty + "'"); //GridView1.DataBind(); tablePMH.Visible = false; btnLuuTam.Enabled = true; btnTiepTu.Enabled = true; } } else { BDepartment bd = BDepartmentBUS.TimMaDonVi(bophan, macongty); Busers2 us = UserBUS.TimMaNhanVienTheoBoPhan(user, bophan, macongty); if (us == null) { Busers2 kiemtra = UserDAO.TimNhanVienQuanLyDonVi(user, bophan, macongty); if (kiemtra == null) { if (ngonngu == "lbl_VN") { lbthongbao.Text = "Người dùng này không thuộc bộ phận " + bd.DepName; tablePMH.Visible = true; btnLuuTam.Enabled = false; btnTiepTu.Enabled = false; } else if (ngonngu == "lbl_TW") { lbthongbao.Text = "该用户不属于部门 " + bd.DepName; tablePMH.Visible = true; btnLuuTam.Enabled = false; btnTiepTu.Enabled = false; } else if (ngonngu == "lbl_EN") { lbthongbao.Text = "The user does not belong to the department" + bd.DepName; tablePMH.Visible = true; btnLuuTam.Enabled = false; btnTiepTu.Enabled = false; } } else { pdna phieun = new pdna(); { phieun.GSBH = macongty; phieun.pdno = maphieu; phieun.pddepid = bophan; phieun.mytitle = tieude; phieun.pdmemovn = noidung; phieun.CFMDate0 = DateTime.Parse(ngaythang); phieun.USERID = user; phieun.Abtype = DropLoaiPhieu.SelectedValue.ToString(); phieun.bixoa = false; phieun.CFMID0 = user; phieun.YN = 5; phieun.bixoa = false; phieun.USERDATE = DateTime.Parse(ngaythang); phieun.UseIntent = txtMucDich.Text; } db.pdnas.InsertOnSubmit(phieun); db.SubmitChanges(); string tenhang = txtTenHang.Text.ToUpper(); //string tenhang = dropTenHang.SelectedValue; string donvitinh = txtdonvitinh.Text.ToUpper(); string soluong = txtSoLuong.Text; string ghichu = txtGhiChu.Text; BOfSupply hang = new BOfSupply(); hang.GSBH = macongty; hang.pdno = maphieu; hang.OfSuppliesName = tenhang; hang.BUnit = donvitinh; hang.BNumber = int.Parse(soluong); hang.BCommnent = ghichu; SuppliesDAO.ThemVatTu(hang); db.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues, db.ExecuteQuery <BOfSupply>("select b.IDOfSupplies,b.OfSuppliesName,b.pdno,b.GSBH,b.BUnit,b.BNumber,b.BCommnent from pdna p left join BOfSupplies b on p.pdno=b.pdno and p.GSBH=b.GSBH where b.pdno='" + maphieu + "' and b.GSBH='" + macongty + "'")); //GridView1.DataSource = db.ExecuteQuery<BOfSupply>("select b.IDOfSupplies,b.OfSuppliesName,b.pdno,b.GSBH,b.BUnit,b.BNumber,b.BCommnent from pdna p left join BOfSupplies b on p.pdno=b.pdno and p.GSBH=b.GSBH where b.pdno='" + maphieu + "' and b.GSBH='" + macongty + "'"); //GridView1.DataBind(); tablePMH.Visible = false; btnLuuTam.Enabled = true; btnTiepTu.Enabled = true; } //Busers2 usertao = UserBUS.TimNhanVienTheoMa(user, macongty); //if (usertao != null && usertao.IDCapDuyet > 12) //{ //} //else //{ // if (ngonngu == "lbl_VN") // { // lbthongbao.Text = "Người dùng này không thuộc bộ phận " + bp; // } // else if (ngonngu == "lbl_TW") // { // lbthongbao.Text = "该用户不属于部门 " + bp; // } // else if (ngonngu == "lbl_EN") // { // lbthongbao.Text = "The user does not belong to the department" + bp; // } //} } else { pdna phieun = new pdna(); { phieun.GSBH = macongty; phieun.pdno = maphieu; phieun.pddepid = bophan; phieun.mytitle = tieude; phieun.pdmemovn = noidung; phieun.CFMDate0 = DateTime.Parse(ngaythang); phieun.USERID = user; phieun.Abtype = DropLoaiPhieu.SelectedValue.ToString(); phieun.bixoa = false; phieun.CFMID0 = user; phieun.YN = 5; phieun.bixoa = false; phieun.USERDATE = DateTime.Parse(ngaythang); phieun.UseIntent = txtMucDich.Text; } db.pdnas.InsertOnSubmit(phieun); db.SubmitChanges(); string tenhang = txtTenHang.Text; //string tenhang = dropTenHang.SelectedValue; string donvitinh = txtdonvitinh.Text; string soluong = txtSoLuong.Text; string ghichu = txtGhiChu.Text; BOfSupply hang = new BOfSupply(); hang.GSBH = macongty; hang.pdno = maphieu; hang.OfSuppliesName = tenhang; hang.BUnit = donvitinh; hang.BNumber = int.Parse(soluong); hang.BCommnent = ghichu; SuppliesDAO.ThemVatTu(hang); db.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues, db.ExecuteQuery <BOfSupply>("select b.IDOfSupplies,b.OfSuppliesName,b.pdno,b.GSBH,b.BUnit,b.BNumber,b.BCommnent from pdna p left join BOfSupplies b on p.pdno=b.pdno and p.GSBH=b.GSBH where b.pdno='" + maphieu + "' and b.GSBH='" + macongty + "'")); //GridView1.DataSource = db.ExecuteQuery<BOfSupply>("select b.IDOfSupplies,b.OfSuppliesName,b.pdno,b.GSBH,b.BUnit,b.BNumber,b.BCommnent from pdna p left join BOfSupplies b on p.pdno=b.pdno and p.GSBH=b.GSBH where b.pdno='" + maphieu + "' and b.GSBH='" + macongty + "'"); //GridView1.DataBind(); tablePMH.Visible = false; btnLuuTam.Enabled = true; btnTiepTu.Enabled = true; } } // them vat tu Session["bp"] = bophan; Session["bophan"] = bp; Session["loaiP"] = loaiP; Session["loaiphieu"] = loaiphieu; Session["maphieu"] = maphieu; Session["noidung"] = noidung; Session["ngaytao"] = ngaythang; Session["tieude"] = tieude; }