protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName.Equals("Insert")) { string macongty = Session["congty"].ToString(); string maphieu = Session["maphieu"].ToString(); TextBox tenhang = (TextBox)GridView1.FooterRow.FindControl("txtAddOfSuppliesName"); TextBox donvitinh = (TextBox)GridView1.FooterRow.FindControl("txtAddBUnit"); TextBox soluong = (TextBox)GridView1.FooterRow.FindControl("txtAddBNumber"); TextBox ghichu = (TextBox)GridView1.FooterRow.FindControl("txtAddBCommnent"); BOfSupply hang = new BOfSupply(); hang.GSBH = macongty; hang.pdno = maphieu; hang.OfSuppliesName = tenhang.Text.ToUpper(); hang.BUnit = donvitinh.Text.ToUpper(); hang.BNumber = int.Parse(soluong.Text); hang.BCommnent = ghichu.Text; SuppliesDAO.ThemVatTu(hang); GridView1.EditIndex = -1; GridView1.DataSource = pnaDAO.LayPhieuMuaHang(maphieu, macongty); GridView1.DataBind(); tenhang.Focus(); } }
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; }
protected void btnKhoiPhuc_Click(object sender, EventArgs e) { string maphieu = Session["maphieu"].ToString(); string macongty = Session["congty"].ToString(); string manguoidung = Session["user"].ToString(); DateTime date = DateTime.Now; //string ngaytao = DateTime.Parse(date.ToShortDateString()).ToString("yyyy/MM/dd"); #region chua dung den //List<Abcon> DSphieu = AbconDAO.QryChiTietPhieuTheoPhieuKhongDuocDuyet(maphieu, macongty, manguoidung); //foreach (Abcon phieu in DSphieu) //{ // AbconDAO.XoaChiTietTheoSoPhieu(phieu.IDCT); //} //List<VanBanDen> DsVanBanden = VanBanDenDAO.QryVanBanDen(maphieu, macongty); //foreach (VanBanDen vanban in DsVanBanden) //{ // VanBanDenDAO.XoaVanBanDen(vanban.id); //} //List<PDNSheetFlow> DsChitiet = PDNSheetFlowDAO.QryPDNSheetFlowTheoPhieu(maphieu, macongty); //foreach (PDNSheetFlow chitiet in DsChitiet) //{ // PDNSheetFlowDAO.XoaPDNSheetFlow(chitiet.Id); //} //ABTrangThaiDuyet trangthai = TrangThaiDuyetDAO.TimKiemMaVanTheoTrangThaiDuyet(maphieu, macongty); //TrangThaiDuyetDAO.XoaTrangThaiDuyet(trangthai.IDTrangThai); #endregion //string dem = (pdnaBUS.DemSoLuongVanBan() + 1).ToString(); //string maphieumoi = DateTime.Parse(DateTime.Now.ToShortDateString()).ToString("yyyyMMdd") + dem; string maphieumoi = ""; 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(); maphieumoi = dem; } else { maphieumoi = DateTime.Parse(DateTime.Now.ToShortDateString()).ToString("yyyyMM") + "00" + 1; } pdna timphieu = pnaDAO.TimVanBanTheoMa(maphieu, macongty, true); db.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues, db.ExecuteQuery<pdna>("select * from pdna where pdno='" + timphieu.pdno.ToString() + "'and GSBH='" + timphieu.GSBH.ToString() + "' and CFMID0='" + timphieu.CFMID0.ToString() + "'")); if (timphieu != null && timphieu.Abtype == "PDN2") { pdna phieub = new pdna(); phieub.pdno = maphieumoi; phieub.YN = 5; phieub.GSBH = macongty; phieub.dagui = false; phieub.bixoa = false; phieub.CFMDate0 = DateTime.Today; phieub.UseIntent = timphieu.UseIntent; phieub.IdnguoiDich = null; phieub.trangthaidich = false; phieub.NoiDungDich = null; phieub.LevelDoing = 1; phieub.CFMID0 = manguoidung; phieub.Abtype = timphieu.Abtype; phieub.ABC = timphieu.ABC; phieub.mytitle = timphieu.mytitle; phieub.pddepid = timphieu.pddepid; phieub.pdmemovn = timphieu.pdmemovn; phieub.oldpdno = timphieu.pdno; pnaDAO.InsertPDNA(phieub); // lay danh sach vat tu theo so phieu List<BOfSupply> list = SuppliesDAO.QryHangTheoPhieu(timphieu.pdno, macongty); foreach (BOfSupply vattu in list) { BOfSupply vt = new BOfSupply(); vt.GSBH = macongty; vt.OfSuppliesName = vattu.OfSuppliesName; vt.pdno = maphieumoi; vt.BUnit = vattu.BUnit; vt.BNumber = vattu.BNumber; vt.BCommnent = vattu.BCommnent; SuppliesDAO.ThemVatTu(vt); } } else { pdna phieub = new pdna(); phieub.pdno = maphieumoi; phieub.YN = 5; phieub.GSBH = macongty; phieub.dagui = false; phieub.bixoa = false; phieub.CFMDate0 = DateTime.Today; phieub.CFMDate1 = null; phieub.CFMDate2 = null; phieub.CFMDate4 = null; phieub.IdnguoiDich = null; phieub.trangthaidich = false; phieub.NoiDungDich = null; phieub.LevelDoing = 0; phieub.CFMID0 = manguoidung; phieub.Abtype = timphieu.Abtype; phieub.ABC = 1; phieub.mytitle = timphieu.mytitle; phieub.pddepid = timphieu.pddepid; phieub.pdmemovn = timphieu.pdmemovn; phieub.oldpdno = timphieu.pdno; pnaDAO.InsertPDNA(phieub); } #region chua dung den //pnaDAO.CapNhatPhieuBiHuy(phieub); //db.ExecuteCommand("update pdna set GSBH='" + phieub.GSBH.ToString() + "',NoiDungDich=N'" + phieub.NoiDungDich.ToString() + "',CFMDate1='" + phieub.CFMDate1 + "',trangthaidich='" + phieub.trangthaidich.Value + "',CFMDate0=N'" + phieub.CFMDate0 + "',CFMDate2=N'" + phieub.CFMDate2 + "',bixoa='" + phieub.bixoa.Value + "',dagui='" + phieub.dagui.Value + "',YN='" + int.Parse(phieub.YN.ToString()) + "',LevelDoing='" + int.Parse(phieub.LevelDoing.ToString()) + "',IdnguoiDich=N'" + phieub.IdnguoiDich.ToString() + "' where pdno=N'" + phieub.pdno.ToString() + "' "); // db.ExecuteCommand("update pdna set GSBH='" + phieub.GSBH.ToString() + "',NoiDungDich=N'" + phieub.NoiDungDich.ToString() + "',trangthaidich='" + phieub.trangthaidich.Value + "',CFMDate0=N'" + phieub.CFMDate0 + "',bixoa='" + phieub.bixoa.Value + "',dagui='" + phieub.dagui.Value + "',YN='" + int.Parse(phieub.YN.ToString()) + "',LevelDoing='" + int.Parse(phieub.LevelDoing.ToString()) + "',IdnguoiDich=N'" + phieub.IdnguoiDich.ToString() + "' where pdno=N'" + phieub.pdno.ToString() + "' "); // db.CapNhatPhieuDaBiHuy(phieub.pdno, phieub.GSBH, phieub.dagui, phieub.bixoa, phieub.YN, phieub.NoiDungDich, phieub.IdnguoiDich, phieub.trangthaidich, phieub.CFMDate1, phieub.CFMDate0, phieub.CFMDate2, phieub.CFMDate4, phieub.ABC, phieub.LevelDoing); #endregion Response.Redirect("Danhsachphieumoikhoitao.aspx"); }