protected void Button1_Click(object sender, EventArgs e) { string macongty = DropCty.SelectedValue.ToString(); string madonvi = DropDownLDonVi.SelectedValue.ToString(); string manguoiduyet = txtNguoiDuyet.Text; int buocduyet = int.Parse(txtBucoDuyet.Text); BDepartment donvi = BDepartmentDAO.TimMaDonVi(madonvi, macongty); AbDepartmentType loaidonvi = LoaiDonViDAO.TimMaLoaiDonVi(int.Parse(donvi.DepartmentTypeID.ToString()), macongty); QuyTrinhXetDuyetCuaCanBo quytrinh = new QuyTrinhXetDuyetCuaCanBo(); //quytrinh.IDQuyTrinh = maquytrinh + (QuyTrinhXetDuyetDAO.DemQuyTrinhXetDuyet() + 1).ToString(); quytrinh.BADEPID = madonvi; quytrinh.tendonviTW = donvi.DepName; quytrinh.GSBH = macongty; //quytrinh.BuocDuyet = buocduyet; quytrinh.IDLoaiDonVi = loaidonvi.DepartmentTypeID; quytrinh.DepartmentTypeNameTW = loaidonvi.DepartmentTypeNameTW; if (DropDownLoaiPhieu.SelectedValue.ToString().Trim() == "") { quytrinh.abtype = "PDN1"; abill timloai = abillBUS.SearchAbillByID(quytrinh.abtype); quytrinh.abtypenameTW = timloai.abnameTW; } else { quytrinh.abtype = DropDownLoaiPhieu.SelectedValue.ToString(); abill timloai = abillBUS.SearchAbillByID(DropDownLoaiPhieu.SelectedValue.ToString()); quytrinh.abtypenameTW = timloai.abnameTW; } if (CheckThongQuaDonVi.Checked == true) { quytrinh.DonViThongQua = DropDownDonViThongQua.SelectedValue.ToString(); BDepartment donvithongqua = BDepartmentDAO.TimMaDonVi(DropDownDonViThongQua.SelectedValue.ToString(), macongty); quytrinh.tendonvithongqua = donvithongqua.DepName; Busers2 timnguoi = UserDAO.TimMaNhanVienTheoBoPhan(txtNguoiDuyet.Text, donvithongqua.ID, macongty); if (timnguoi == null) { quytrinh.NguoiDuyet = null; } else { quytrinh.NguoiDuyet = txtNguoiDuyet.Text; quytrinh.USERNAME = timnguoi.USERNAME; ChucVu chuc = ChucVuDAO.TimMaChucVu(timnguoi.IDChucVu, macongty); quytrinh.IDChucVu = chuc.IDChucVu; quytrinh.tendonvithongqua = chuc.TenChucVuTiengHoa; quytrinh.IDCapDuyet = timnguoi.IDCapDuyet; } } else { quytrinh.DonViThongQua = null; quytrinh.NguoiDuyet = txtNguoiDuyet.Text; Busers2 nguoi = UserDAO.TimNhanVienTheoMa(manguoiduyet, macongty); quytrinh.USERNAME = nguoi.USERNAME; ChucVu chuc = ChucVuDAO.TimMaChucVu(nguoi.IDChucVu, macongty); quytrinh.IDChucVu = chuc.IDChucVu; quytrinh.tendonvithongqua = chuc.TenChucVuTiengHoa; quytrinh.IDCapDuyet = nguoi.IDCapDuyet; } #region ThemQuyTrinh List <QuyTrinhXetDuyetCuaCanBo> ListQT1 = QuyTrinhXetDuyetCuaCanBoDAO.LayDanhSachQuyTrinhTheoCapDuyet(quytrinh.BADEPID, quytrinh.GSBH, quytrinh.abtype); int max1 = (from ct1 in ListQT1 select int.Parse(ct1.BuocDuyet.ToString())).Max(); quytrinh.BuocDuyet = max1 + 1; QuyTrinhXetDuyetCuaCanBo timquynguoi = QuyTrinhXetDuyetCuaCanBoDAO.TimNguoiTrongQuyTrinh(quytrinh.NguoiDuyet, quytrinh.abtype, quytrinh.BADEPID, quytrinh.GSBH); Busers2 timnguoiduyettrong = UserDAO.TimNhanVienTheoMa(quytrinh.NguoiDuyet, quytrinh.GSBH); if (timquynguoi == null && quytrinh.NguoiDuyet != null) { QuyTrinhXetDuyetCuaCanBoDAO.ThemQuyTrinhXetDuyetCuaCanBo(quytrinh);// them quy trinh List <QuyTrinhXetDuyetCuaCanBo> ListQT = QuyTrinhXetDuyetCuaCanBoDAO.LayDanhSachQuyTrinhTheoCapDuyet(quytrinh.BADEPID, quytrinh.GSBH, quytrinh.abtype); int min = (from ct1 in ListQT select int.Parse(ct1.BuocDuyet.ToString())).Min(); int min1 = (from ct1 in ListQT select int.Parse(ct1.IDCapDuyet.ToString())).Min(); foreach (QuyTrinhXetDuyetCuaCanBo qt in ListQT) { QuyTrinhXetDuyetCuaCanBo laynguoidautien = QuyTrinhXetDuyetCuaCanBoDAO.TimCapTiepTheoTrongQuyTrinh1(qt.BADEPID, qt.GSBH, qt.abtype, min1); if (qt.NguoiDuyet == laynguoidautien.NguoiDuyet) { QuyTrinhXetDuyetCuaCanBo quy = new QuyTrinhXetDuyetCuaCanBo(); quy.BuocDuyet = 1; quy.IDQuyTrinh = qt.IDQuyTrinh; buoc = 1; capduyet = int.Parse(qt.IDCapDuyet.ToString()); QuyTrinhXetDuyetCuaCanBoDAO.CapNhatQuyTrinh(quy); } else { //QuyTrinhXetDuyet laybuoc= QuyTrinhXetDuyetDAO.TimBuocTiepTheoTrongQuyTrinh1(qt.BADEPID, qt.GSBH, qt.abtype, int.Parse(qt.BuocDuyet.ToString())); if (qt.DonViThongQua == null && capduyet == qt.IDCapDuyet) { QuyTrinhXetDuyetCuaCanBo quy = new QuyTrinhXetDuyetCuaCanBo(); quy.BuocDuyet = buoc; quy.IDQuyTrinh = qt.IDQuyTrinh; buoc = int.Parse(quy.BuocDuyet.ToString()); capduyet = int.Parse(qt.IDCapDuyet.ToString()); QuyTrinhXetDuyetCuaCanBoDAO.CapNhatQuyTrinh(quy); } else { QuyTrinhXetDuyetCuaCanBo quy = new QuyTrinhXetDuyetCuaCanBo(); quy.BuocDuyet = buoc + 1; quy.IDQuyTrinh = qt.IDQuyTrinh; buoc = int.Parse(quy.BuocDuyet.ToString()); capduyet = int.Parse(qt.IDCapDuyet.ToString()); QuyTrinhXetDuyetCuaCanBoDAO.CapNhatQuyTrinh(quy); } } } } #endregion ///////////////////////////////////// code by Mr Tuan QuyTrinhXetDuyetCuaCanBo timng = QuyTrinhXetDuyetCuaCanBoDAO.TimNguoiTrongQuyTrinh(manguoiduyet, quytrinh.abtype, madonvi, macongty); List <Abcon> list = AbconDAO.LayDanhSachPhieuTaiCapDuyetChuaDuyet(madonvi, quytrinh.abtype, macongty, int.Parse(timng.BuocDuyet.ToString())); foreach (Abcon l in list) { buocthemvao = l.abde; if (l.IDCapDuyet > timng.IDCapDuyet) { List <Abcon> danh = AbconDAO.LayDanhSachPhieuTaiCapDuyetChuaDuyet1(l.from_depart, l.abtype, l.Gsbh, l.pdno, int.Parse(timng.BuocDuyet.ToString())); foreach (Abcon aa in danh) { if (timng.BuocDuyet == aa.Abstep && timng.DonViThongQua == null && timng.IDCapDuyet == aa.IDCapDuyet) { Abcon aabcc = new Abcon(); aabcc.abtype = aa.abtype; aabcc.pdno = aa.pdno; aabcc.Gsbh = aa.Gsbh; aabcc.IDCT = aa.IDCT; aabcc.Abstep = aa.Abstep; aabcc.abde = aa.abde + 1; AbconDAO.CapNhatPhieuChuyen(aabcc); } else { Abcon aabcc = new Abcon(); aabcc.abtype = aa.abtype; aabcc.pdno = aa.pdno; aabcc.Gsbh = aa.Gsbh; aabcc.IDCT = aa.IDCT; aabcc.Abstep = aa.Abstep + 1; aabcc.abde = aa.abde + 1; AbconDAO.CapNhatPhieuChuyen(aabcc); } } } else { if (l.IDCapDuyet == timng.IDCapDuyet && l.Abstep == timng.BuocDuyet) { List <Abcon> danh = AbconDAO.LayDanhSachPhieuTaiCapDuyetChuaDuyet1(l.from_depart, l.abtype, l.Gsbh, l.pdno, int.Parse(timng.BuocDuyet.ToString())); foreach (Abcon aa in danh) { if (timng.BuocDuyet == aa.Abstep && timng.DonViThongQua == null && timng.IDCapDuyet == aa.IDCapDuyet) { Abcon aabcc = new Abcon(); aabcc.abtype = aa.abtype; aabcc.pdno = aa.pdno; aabcc.Gsbh = aa.Gsbh; aabcc.IDCT = aa.IDCT; aabcc.Abstep = aa.Abstep; aabcc.abde = aa.abde + 1; AbconDAO.CapNhatPhieuChuyen(aabcc); } else { Abcon aabcc = new Abcon(); aabcc.abtype = aa.abtype; aabcc.pdno = aa.pdno; aabcc.Gsbh = aa.Gsbh; aabcc.IDCT = aa.IDCT; aabcc.Abstep = aa.Abstep + 1; aabcc.abde = aa.abde + 1; AbconDAO.CapNhatPhieuChuyen(aabcc); } } } else { List <Abcon> danh = AbconDAO.LayDanhSachPhieuTaiCapDuyetChuaDuyet1(l.from_depart, l.abtype, l.Gsbh, l.pdno, int.Parse(timng.BuocDuyet.ToString())); foreach (Abcon aa in danh) { if (timng.BuocDuyet == aa.Abstep && timng.DonViThongQua == null && timng.IDCapDuyet == aa.IDCapDuyet) { Abcon aabcc = new Abcon(); aabcc.abtype = aa.abtype; aabcc.pdno = aa.pdno; aabcc.Gsbh = aa.Gsbh; aabcc.IDCT = aa.IDCT; aabcc.Abstep = aa.Abstep; aabcc.abde = aa.abde + 1; AbconDAO.CapNhatPhieuChuyen(aabcc); } else { Abcon aabcc = new Abcon(); aabcc.abtype = aa.abtype; aabcc.pdno = aa.pdno; aabcc.Gsbh = aa.Gsbh; aabcc.IDCT = aa.IDCT; aabcc.Abstep = aa.Abstep + 1; aabcc.abde = aa.abde + 1; AbconDAO.CapNhatPhieuChuyen(aabcc); } } } } //them phieu //kiemtamaphieu = l.pdno; Abcon abco = new Abcon(); abco.ABC = l.ABC; abco.abde = buocthemvao; abco.ABJOB = l.ABJOB; abco.abmomo = l.abmomo; abco.Abstep = int.Parse(timng.BuocDuyet.ToString()); abco.abrult = false; abco.abtype = l.abtype; abco.Auditor = timng.NguoiDuyet; abco.bixoa = false; abco.boqua = false; abco.cothutu = true; abco.from_depart = l.from_depart; abco.from_user = l.from_user; abco.Gsbh = l.Gsbh; abco.Id_VB_CD = l.Id_VB_CD; abco.IDCapDuyet = timng.IDCapDuyet; abco.IDChiTiet = l.IDChiTiet; abco.kytoanbo = true; abco.lydokhongduyet = l.lydokhongduyet; abco.Maintitle = l.Maintitle; abco.ncancel = 0; abco.Nhom = l.Nhom; abco.Password2 = null; abco.pdno = l.pdno; abco.received = l.received; abco.signatue = null; abco.Userdate = l.Userdate; abco.Yn = 4; AbconBUS.ThemChiTiet(abco); } HienThiDanhSach(); }
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { int idquytrinh = int.Parse(GridView1.Rows[e.RowIndex].Cells[2].Text); //QuyTrinhXetDuyet quytrinh = QuyTrinhXetDuyetDAO.TimMaQuytrinh(idquytrinh); string macongty = GridView1.Rows[e.RowIndex].Cells[3].Text; string maloaiphieu = GridView1.Rows[e.RowIndex].Cells[4].Text; string madonvi = GridView1.Rows[e.RowIndex].Cells[6].Text; string madonvithongqua = GridView1.Rows[e.RowIndex].Cells[8].Text; string manguoiduyet = GridView1.Rows[e.RowIndex].Cells[11].Text; string machucvu = GridView1.Rows[e.RowIndex].Cells[13].Text; string macapduyet = GridView1.Rows[e.RowIndex].Cells[15].Text; string maloaidonvi = GridView1.Rows[e.RowIndex].Cells[16].Text; string buoduyet = GridView1.Rows[e.RowIndex].Cells[10].Text; QuyTrinhXetDuyetCuaCanBoDAO.XoaQuyTrinhXetDuyetTheoCanBo(idquytrinh); List <QuyTrinhXetDuyetCuaCanBo> ListQT = QuyTrinhXetDuyetCuaCanBoDAO.LayDanhSachQuyTrinhTheoCapDuyet(madonvi, macongty, maloaiphieu); int min = (from ct1 in ListQT select int.Parse(ct1.BuocDuyet.ToString())).Min(); int min1 = (from ct1 in ListQT select int.Parse(ct1.IDCapDuyet.ToString())).Min(); foreach (QuyTrinhXetDuyetCuaCanBo qt in ListQT) { QuyTrinhXetDuyetCuaCanBo laynguoidautien = QuyTrinhXetDuyetCuaCanBoDAO.TimCapTiepTheoTrongQuyTrinh1(qt.BADEPID, qt.GSBH, qt.abtype, min1); if (qt.NguoiDuyet == laynguoidautien.NguoiDuyet) { QuyTrinhXetDuyetCuaCanBo quy = new QuyTrinhXetDuyetCuaCanBo(); quy.BuocDuyet = 1; quy.IDQuyTrinh = qt.IDQuyTrinh; buoc = 1; capduyet = int.Parse(qt.IDCapDuyet.ToString()); QuyTrinhXetDuyetCuaCanBoDAO.CapNhatQuyTrinh(quy); } else { //QuyTrinhXetDuyet laybuoc= QuyTrinhXetDuyetDAO.TimBuocTiepTheoTrongQuyTrinh1(qt.BADEPID, qt.GSBH, qt.abtype, int.Parse(qt.BuocDuyet.ToString())); if (qt.DonViThongQua == null && capduyet == qt.IDCapDuyet) { QuyTrinhXetDuyetCuaCanBo quy = new QuyTrinhXetDuyetCuaCanBo(); quy.BuocDuyet = buoc; quy.IDQuyTrinh = qt.IDQuyTrinh; buoc = int.Parse(quy.BuocDuyet.ToString()); capduyet = int.Parse(qt.IDCapDuyet.ToString()); QuyTrinhXetDuyetCuaCanBoDAO.CapNhatQuyTrinh(quy); } else { QuyTrinhXetDuyetCuaCanBo quy = new QuyTrinhXetDuyetCuaCanBo(); quy.BuocDuyet = buoc + 1; quy.IDQuyTrinh = qt.IDQuyTrinh; buoc = int.Parse(quy.BuocDuyet.ToString()); capduyet = int.Parse(qt.IDCapDuyet.ToString()); QuyTrinhXetDuyetCuaCanBoDAO.CapNhatQuyTrinh(quy); } } } HienThiDanhSach(); }
protected void Button1_Click(object sender, EventArgs e) { string manguoiduyet1 = Session["manguoiduyet"].ToString(); int id = int.Parse(Session["id"].ToString()); string macongty = DropCty.SelectedValue.ToString(); string madonvi = DropDownLDonVi.SelectedValue.ToString(); string manguoiduyet = txtNguoiDuyet.Text; // int buocduyet = int.Parse(txtBucoDuyet.Text); BDepartment donvi = BDepartmentDAO.TimMaDonVi(madonvi, macongty); AbDepartmentType loaidonvi = LoaiDonViDAO.TimMaLoaiDonVi(int.Parse(donvi.DepartmentTypeID.ToString()), macongty); QuyTrinhXetDuyetCuaCanBo quytrinh = new QuyTrinhXetDuyetCuaCanBo(); //quytrinh.IDQuyTrinh = maquytrinh + (QuyTrinhXetDuyetDAO.DemQuyTrinhXetDuyet() + 1).ToString(); quytrinh.BADEPID = madonvi; quytrinh.IDQuyTrinh = id; quytrinh.tendonviTW = donvi.DepName; quytrinh.GSBH = macongty; //quytrinh.BuocDuyet = buocduyet; quytrinh.IDLoaiDonVi = loaidonvi.DepartmentTypeID; quytrinh.DepartmentTypeNameTW = loaidonvi.DepartmentTypeNameTW; if (cbLoaiPhieu.Checked == true) { quytrinh.abtype = DropDownLoaiPhieu.SelectedValue.ToString(); abill timloai = abillBUS.SearchAbillByID(DropDownLoaiPhieu.SelectedValue.ToString()); quytrinh.abtypenameTW = timloai.abnameTW; } else { quytrinh.abtype = "PDN1"; } if (CheckThongQuaDonVi.Checked == true) { quytrinh.DonViThongQua = DropDownDonViThongQua.SelectedValue.ToString(); BDepartment donvithongqua = BDepartmentDAO.TimMaDonVi(DropDownDonViThongQua.SelectedValue.ToString(), macongty); quytrinh.tendonvithongqua = donvithongqua.DepName; } else { quytrinh.DonViThongQua = null; } if (txtNguoiDuyet.Text.Trim() == "") { quytrinh.NguoiDuyet = "MD"; } else { quytrinh.NguoiDuyet = manguoiduyet; Busers2 nguoi = UserDAO.TimNhanVienTheoMa(manguoiduyet, macongty); quytrinh.USERNAME = nguoi.USERNAME; ChucVu chuc = ChucVuDAO.TimMaChucVu(nguoi.IDChucVu, macongty); quytrinh.IDChucVu = chuc.IDChucVu; quytrinh.tendonvithongqua = chuc.TenChucVuTiengHoa; quytrinh.IDCapDuyet = nguoi.IDCapDuyet; } List <QuyTrinhXetDuyetCuaCanBo> ListQT1 = QuyTrinhXetDuyetCuaCanBoDAO.LayDanhSachQuyTrinhTheoCapDuyet(quytrinh.BADEPID, quytrinh.GSBH, quytrinh.abtype); int max1 = (from ct1 in ListQT1 select int.Parse(ct1.BuocDuyet.ToString())).Max(); quytrinh.BuocDuyet = max1 + 1; QuyTrinhXetDuyetCuaCanBoDAO.SuaQuyTrinhXetDuyetTheoCanBo(quytrinh); QuyTrinhXetDuyetCuaCanBo timquynguoi = QuyTrinhXetDuyetCuaCanBoDAO.TimNguoiTrongQuyTrinh(quytrinh.NguoiDuyet, quytrinh.abtype, quytrinh.BADEPID, quytrinh.GSBH); Busers2 timnguoiduyettrong = UserDAO.TimNhanVienTheoMa(quytrinh.NguoiDuyet, quytrinh.GSBH); if (timquynguoi != null) { List <QuyTrinhXetDuyetCuaCanBo> ListQT = QuyTrinhXetDuyetCuaCanBoDAO.LayDanhSachQuyTrinhTheoCapDuyet(quytrinh.BADEPID, quytrinh.GSBH, quytrinh.abtype); int min = (from ct1 in ListQT select int.Parse(ct1.BuocDuyet.ToString())).Min(); int min1 = (from ct1 in ListQT select int.Parse(ct1.IDCapDuyet.ToString())).Min(); foreach (QuyTrinhXetDuyetCuaCanBo qt in ListQT) { QuyTrinhXetDuyetCuaCanBo laynguoidautien = QuyTrinhXetDuyetCuaCanBoDAO.TimCapTiepTheoTrongQuyTrinh1(qt.BADEPID, qt.GSBH, qt.abtype, min1); if (qt.NguoiDuyet == laynguoidautien.NguoiDuyet) { QuyTrinhXetDuyetCuaCanBo quy = new QuyTrinhXetDuyetCuaCanBo(); quy.BuocDuyet = 1; quy.IDQuyTrinh = qt.IDQuyTrinh; buoc = 1; QuyTrinhXetDuyetCuaCanBoDAO.CapNhatQuyTrinh(quy); } else { QuyTrinhXetDuyetCuaCanBo quy = new QuyTrinhXetDuyetCuaCanBo(); quy.BuocDuyet = buoc + 1; quy.IDQuyTrinh = qt.IDQuyTrinh; buoc = int.Parse(quy.BuocDuyet.ToString()); QuyTrinhXetDuyetCuaCanBoDAO.CapNhatQuyTrinh(quy); } } } List <Abcon> LayDanhSach = AbconDAO.LayDanhSachVanBanChuaDuyetTheoNguoiDuyet(madonvi, quytrinh.abtype, macongty, manguoiduyet1); if (manguoiduyet1 == manguoiduyet) { } else { Busers2 nguoi = UserDAO.TimNhanVienTheoMa(manguoiduyet, macongty); foreach (Abcon ct in LayDanhSach) { //Abcon tim = AbconDAO.TimNguoiDuyetTrongPhieu(madonvi, macongty, quytrinh.abtype, ct.pdno, manguoiduyet); //int buockietiep=ct.abde+1 //Abcon kiemtra = AbconDAO.TimBuocKyTruocTrongPhieu(ct.from_depart, ct.Gsbh, ct.abtype, ct.pdno, buocketiep); Abcon chitiet = new Abcon(); chitiet.IDCT = ct.IDCT; chitiet.Auditor = manguoiduyet; chitiet.Gsbh = ct.Gsbh; chitiet.pdno = ct.pdno; chitiet.abmomo = ct.abmomo; chitiet.abtype = ct.abtype; chitiet.abrult = false; chitiet.abde = ct.abde; chitiet.ABC = ct.ABC; chitiet.bixoa = false; chitiet.boqua = false; chitiet.cothutu = true; chitiet.from_depart = ct.from_depart; chitiet.from_user = ct.from_user; chitiet.Id_VB_CD = ct.Id_VB_CD; chitiet.Maintitle = ct.Maintitle; chitiet.Yn = 4; chitiet.IDCapDuyet = nguoi.IDCapDuyet; AbconDAO.SuaChiTietXD1(chitiet, true); } } Response.Redirect("FQuyTrinhXetDuyet.aspx"); }