Esempio n. 1
0
        protected void btnTrinhDuyet_Click(object sender, EventArgs e)
        {
            List <Abcon> ctxdlist = new List <Abcon>();
            pdna         phieudn  = new pdna();

            try
            {
                string maloai  = Session["loaiphieu"].ToString();
                string phieu   = Session["maphieu"].ToString();
                string bophan  = Session["bp"].ToString();
                string noidung = Session["noidung"].ToString();
                string tieude  = Session["tieude"].ToString();
                string congty  = Session["congty"].ToString();
                string user    = Session["user"].ToString();


                //string ngaytao = DateTime.Parse(DateTime.Now.ToShortDateString()).ToString("yyyy-MM-dd");
                pdna phieun = new pdna();
                {
                    phieun.GSBH       = congty;
                    phieun.pdno       = phieu;
                    phieun.pddepid    = bophan;
                    phieun.mytitle    = tieude;
                    phieun.pdmemovn   = noidung;
                    phieun.CFMDate0   = DateTime.Parse(DateTime.Now.ToShortDateString());
                    phieun.USERID     = user;
                    phieun.CFMID0     = user;
                    phieun.bixoa      = false;
                    phieun.YN         = 0;
                    phieun.USERDATE   = DateTime.Parse(DateTime.Now.ToShortDateString());
                    phieun.ABC        = Convert.ToInt32(DropUutien.SelectedValue.ToString());
                    phieun.LevelDoing = 1;
                }
                db.pdnas.InsertOnSubmit(phieun);
                db.SubmitChanges();
                for (int i = 0; i < TreeView1.Nodes[0].ChildNodes.Count; i++)
                {
                    TreeNode tn = TreeView1.Nodes[0].ChildNodes[i];
                    tn.Value = (i + 1).ToString();

                    foreach (TreeNode node in tn.ChildNodes)
                    {
                        Abcon vb = new Abcon();
                        if (ctxds.TryGetValue(tn.Text, out vb))
                        {
                            // vb.IDCT = MA_CTXetDuyet + (AbconBUS.DemSoLuongMaVanBan_CapDuyet() + 1).ToString();
                            vb.abde    = int.Parse(tn.Value.ToString());
                            vb.pdno    = phieu;
                            vb.cothutu = true;
                            vb.Abstep  = int.Parse(tn.Value.ToString());
                            AbconBUS.ThemChiTiet(vb);
                            ctxdlist.Add(vb);
                        }
                    }
                }
                foreach (string str in lstIdNguoiNhan)
                {
                    Abcon   temp        = AbconBUS.TimKiemVanBanDenTheoIdVanBan_IdNguoiNhan(phieudn.pdno, str, phieudn.CFMID0, false);
                    string  manguoidung = Session["user"].ToString();
                    string  macongty    = Session["congty"].ToString();
                    Busers2 nguoi       = UserBUS.TimNhanVienTheoMa(manguoidung, macongty);
                    if (temp != null)
                    {
                        continue;
                    }
                    Abcon vbd = new Abcon();
                    vbd.from_user = nguoi.USERID;
                    vbd.Auditor   = str;
                    //vbd.pdnoreceived = phieudn.pdno;
                    vbd.from_depart = phieudn.pddepid;
                    vbd.bixoa       = true;
                    AbconBUS.ThemChiTiet(vbd);
                }
            }
            catch (TimeoutException ex)
            {
                foreach (Abcon ct in ctxdlist)
                {
                    AbconBUS.XoaChiTiet(ct.IDCT, false);
                }
                string  manguoidung = Session["user"].ToString();
                string  macongty    = Session["congty"].ToString();
                Busers2 nguoi       = UserBUS.TimNhanVienTheoMa(manguoidung, macongty);

                pdnaBUS.XoaVanBan(phieudn, false);
                Until.WriteFileLogServer(nguoi.USERNAME + "\tTạo văn bản\t" + phieudn.pdno + "\tThất bại.");
                LbThongBao.Text = "Lỗi trong quá trình xử lý";
            }
            catch (Exception)
            {
                foreach (Abcon ct in ctxdlist)
                {
                    AbconBUS.XoaChiTiet(ct.IDCT, false);
                }

                string  manguoidung = Session["user"].ToString();
                string  macongty    = Session["congty"].ToString();
                Busers2 nguoi       = UserBUS.TimNhanVienTheoMa(manguoidung, macongty);
                pdnaBUS.XoaVanBan(phieudn, false);
                Until.WriteFileLogServer(nguoi.USERNAME + "\tTạo văn bản\t" + phieudn.pdno + "\tThất bại.");
                LbThongBao.Text = "Lỗi trong quá trình xử lý";
            }
        }