Ejemplo n.º 1
0
        private void HienThi()
        {
            string idphieu = Session["maphieu"].ToString();
            //string bophan = Session["bophan"].ToString();

            //string noidung = Session["noidung"].ToString();
            //string ngaytao = Session["ngaythang"].ToString();
            string      user   = Session["user"].ToString();
            string      bp     = Session["bp"].ToString();
            string      congty = Session["congty"].ToString();
            BDepartment bophan = BDepartmentBUS.TimMaDonVi(bp, congty);
            //string loaiphieu = Session["loaiphieu"].ToString();
            pdna  phieu     = pdnaBUS.TimVanBanTheoMa(idphieu, congty, true);
            abill loaiphieu = abillBUS.SearchAbillByID(phieu.Abtype);


            string tenloaiphieuVN = loaiphieu.abname;
            string tenloaiphieuTW = loaiphieu.abnameTW;

            lbLoaiPhieu.Text = tenloaiphieuVN + " " + tenloaiphieuTW;

            lbBoPhan.Text      = bophan.DepName;
            lbSoPhieu.Text     = idphieu;
            lbNoiDung.Text     = phieu.pdmemovn;
            LbNoiDungDich.Text = phieu.NoiDungDich;
            //lbNgay.Text = phieu.CFMDate0.ToString();

            string dinhdang = phieu.CFMDate0.ToString();
            string thang    = dinhdang.Substring(3, 2);
            string ngay     = dinhdang.Substring(0, 2);
            string nam      = dinhdang.Substring(6, 4);

            lbNgay.Text = "Ngày 日  " + ngay + " Tháng 月 " + thang + " Năm 年 " + nam + "";
            Busers2 user0 = AbconBUS.LayMaNguoiTaoTheoIDVanBan(idphieu, congty);

            if (user0 != null)
            {
                TextBox1.Text = user0.USERID;
                //ImageLevel0.ImageUrl = users.signatue;
                ImageLevel0.Width    = 100;
                ImageLevel0.Height   = 100;
                ImageLevel0.ImageUrl = "~/MyPhoto.ashx?USERID=" + TextBox1.Text;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["user"] == null)
            {
                //Response.Redirect("~/presentationLayer/DangNhap.aspx");
                Response.Redirect("http://portal.footgear.com.vn");
            }
            string maphieu     = Session["maphieu"].ToString();
            string macongty    = Session["congty"].ToString();
            string manguoidung = Session["user"].ToString();

            //pdna phieu = pnaDAO.LayVanBanDaDichTheoNguoiDich(maphieu, macongty, manguoidung);
            db.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues, db.ExecuteQuery <pdna>("select * from pdna where pdno='" + maphieu + "'and GSBH='" + macongty + "' and IdnguoiDich='" + manguoidung + "'"));
            var list = db.ExecuteQuery <pdna>("select * from pdna where pdno='" + maphieu + "'and GSBH='" + macongty + "' and IdnguoiDich='" + manguoidung + "'");

            foreach (pdna phieu in list)
            {
                BDepartment bophan    = BDepartmentBUS.TimMaDonVi(phieu.pddepid, macongty);
                abill       loaiphieu = abillBUS.SearchAbillByID(phieu.Abtype);
                if (!IsPostBack)
                {
                    string tenloaiphieuVN = loaiphieu.abname;
                    string tenloaiphieuTW = loaiphieu.abnameTW;

                    lbLoaiPhieu.Text = tenloaiphieuVN + " " + tenloaiphieuTW;
                    lbBoPhan.Text    = bophan.DepName;
                    lbLoaiPhieu.Text = loaiphieu.abname;
                    //lbNgay.Text = ;
                    txtTieuDe.Text = phieu.pdnsubject;
                    lbNoiDung.Text = phieu.pdmemovn;
                    lbSoPhieu.Text = phieu.pdno;
                    string dinhdang = phieu.CFMDate0.ToString();
                    string thang    = dinhdang.Substring(3, 2);
                    string ngay     = dinhdang.Substring(0, 2);
                    string nam      = dinhdang.Substring(6, 4);
                    lbNgay.Text               = "Ngày 日  " + ngay + " Tháng 月 " + thang + " Năm 年 " + nam + "";
                    CKEditorControl1.Text     = phieu.NoiDungDich;
                    CKEditorControl1.ReadOnly = true;
                    CKEditorControl1.Enabled  = false;
                    btnLuu.Enabled            = false;
                }
            }
        }
        private void HienThiThongTin()
        {
            string maphieu     = Session["maphieu"].ToString();
            string macongty    = Session["congty"].ToString();
            string manguoidung = Session["user"].ToString();



            DataTable dt = dal.TimPhieuTheoMaNguoiTao(maphieu, macongty, manguoidung);

            if (dt.Rows.Count > 0)
            {
                // string ngaythang = DateTime.Parse(phieu.CFMDate0.ToString("dd/MM/yyyy"));
                string      madonvi        = dt.Rows[0]["pddepid"].ToString();
                string      maloaiphieu    = dt.Rows[0]["Abtype"].ToString();
                BDepartment bophan         = BDepartmentBUS.TimMaDonVi(madonvi, macongty);
                abill       loaiphieu      = abillBUS.SearchAbillByID(maloaiphieu);
                string      tenloaiphieuVN = loaiphieu.abname;
                string      tenloaiphieuTW = loaiphieu.abnameTW;
                txtTieuDe.Text   = dt.Rows[0]["mytitle"].ToString();
                lbLoaiPhieu.Text = tenloaiphieuVN + " " + tenloaiphieuTW;
                //lbNgay.Text = ;
                //CKEditorControl1.Text = phieu.pdmemovn;
                lbBoPhan.Text  = bophan.DepName;
                lbSoPhieu.Text = dt.Rows[0]["pdno"].ToString();
                string dinhdang = dt.Rows[0]["CFMDate0"].ToString();
                string thang    = dinhdang.Substring(3, 2);
                string ngay     = dinhdang.Substring(0, 2);
                string nam      = dinhdang.Substring(6, 4);
                lbNgay.Text           = "Ngày 日  " + ngay + " Tháng 月 " + thang + " Năm 年 " + nam + "";
                CKEditorControl1.Text = dt.Rows[0]["pdmemovn"].ToString();

                DropDownNguoiDich.Enabled = false;
                HienThiNguoiDich();
                btnLuu.Enabled = false;
                btnLuu.Attributes.CssStyle.Add("opacity", "0.3");
            }
            CKEditorControl1.Enabled = false;
        }
Ejemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Session["user"] == null)
                {
                    //Response.Redirect("~/presentationLayer/DangNhap.aspx");
                    Response.Redirect("http://portal.footgear.com.vn");
                }
                string strNgonngu = (string)Session["languege"];
                if (strNgonngu != null)
                {
                    LayngonNgu(33, strNgonngu);
                }
                else
                {
                    Response.Redirect("http://portal.footgear.com.vn");
                }
                GanNgonNguVaoConTrol();
                string maphieu     = Session["maphieu"].ToString();
                string macongty    = Session["congty"].ToString();
                string manguoidung = Session["user"].ToString();
                //pdna phieu = pnaDAO.LayVanBanTheoNguoiTrinh(maphieu, macongty, manguoidung);
                DataTable dt = dal.TimPhieuTheoMaNguoiTao(maphieu, macongty, manguoidung);
                if (dt.Rows.Count > 0)
                {
                    string ngaythang   = dt.Rows[0]["CFMDate0"].ToString();
                    string madonvi     = dt.Rows[0]["pddepid"].ToString().Trim();
                    string maloaiphieu = dt.Rows[0]["Abtype"].ToString().Trim();
                    string noidung     = dt.Rows[0]["pdmemovn"].ToString().Trim();
                    string tieude      = dt.Rows[0]["mytitle"].ToString().Trim();
                    string tieudedich  = dt.Rows[0]["pdnsubject"].ToString().Trim();
                    string noidungdich = dt.Rows[0]["NoiDungDich"].ToString();
                    int    Yn          = int.Parse(dt.Rows[0]["Yn"].ToString());
                    Session["loaiphieu"]   = maloaiphieu;
                    Session["bp"]          = madonvi;
                    Session["noidung"]     = noidung;
                    Session["noidungdich"] = noidungdich;
                    Session["tieude"]      = tieude;


                    if (Yn == 6)
                    {
                        BDepartment bophan    = BDepartmentBUS.TimMaDonVi(madonvi, macongty);
                        abill       loaiphieu = abillBUS.SearchAbillByID(maloaiphieu);

                        string tenloaiphieuVN = loaiphieu.abname;
                        string tenloaiphieuTW = loaiphieu.abnameTW;

                        lbLoaiPhieu.Text = tenloaiphieuVN + " " + tenloaiphieuTW;
                        string dinhdang = ngaythang;
                        string thang    = dinhdang.Substring(3, 2);
                        string ngay     = dinhdang.Substring(0, 2);
                        string nam      = dinhdang.Substring(6, 4);
                        lbNgay.Text    = "Ngày 日  " + ngay + " Tháng 月 " + thang + " Năm 年 " + nam + "";
                        lbBoPhan.Text  = bophan.DepName;
                        lblTieuDe.Text = tieude + " " + tieudedich;

                        lbNoiDung.Text     = noidungdich;
                        lbSoPhieu.Text     = maphieu;
                        LbNoiDungDich.Text = noidungdich;
                    }
                }
            }
        }
Ejemplo n.º 5
0
        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;
        }
Ejemplo n.º 6
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            string ngonngu = Session["languege"].ToString();
            string dem     = (pdnaBUS.DemSoLuongVanBan() + 1).ToString();
            string maphieu = DateTime.Parse(DateTime.Now.ToShortDateString()).ToString("yyyyMMdd") + dem;
            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();

            if (loaiphieu != "PDN2")
            {
                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;
                            }
                            else if (ngonngu == "lbl_TW")
                            {
                                lbthongbao.Text = "该用户不属于部门 " + bd.DepName;
                            }
                            else if (ngonngu == "lbl_EN")
                            {
                                lbthongbao.Text = "The user does not belong to the department" + bd.DepName;
                            }
                        }
                        else
                        {
                            pdna phieun = new pdna();
                            {
                                phieun.pdno = maphieu;

                                phieun.GSBH     = macongty;
                                phieun.pdno     = maphieu;
                                phieun.Abtype   = loaiphieu;
                                phieun.pddepid  = bophan;
                                phieun.mytitle  = tieude;
                                phieun.pdmemovn = noidung;
                                phieun.CFMDate0 = DateTime.Parse(ngaythang);
                                phieun.CFMID0   = user;
                                phieun.USERID   = user;
                                phieun.dagui    = false;
                                phieun.bixoa    = false;
                            }
                            db.pdnas.InsertOnSubmit(phieun);
                            db.SubmitChanges();
                            Session["bp"]        = bophan;
                            Session["bophan"]    = bp;
                            Session["loaiP"]     = loaiP;
                            Session["loaiphieu"] = loaiphieu;
                            Session["maphieu"]   = maphieu;

                            Session["noidung"] = noidung;
                            Session["ngaytao"] = ngaythang;
                            Session["tieude"]  = tieude;
                            Response.Redirect("FrmViewCB.aspx");
                        }
                        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;
                            }
                            else if (ngonngu == "lbl_TW")
                            {
                                lbthongbao.Text = "该用户不属于部门 " + bd.DepName;
                            }
                            else if (ngonngu == "lbl_EN")
                            {
                                lbthongbao.Text = "The user does not belong to the department" + bd.DepName;
                            }
                        }
                    }
                    else
                    {
                        pdna phieun = new pdna();
                        {
                            phieun.pdno = maphieu;

                            phieun.GSBH     = macongty;
                            phieun.pdno     = maphieu;
                            phieun.Abtype   = loaiphieu;
                            phieun.pddepid  = bophan;
                            phieun.mytitle  = tieude;
                            phieun.pdmemovn = noidung;
                            phieun.CFMDate0 = DateTime.Parse(ngaythang);
                            phieun.CFMID0   = user;
                            phieun.USERID   = user;
                            phieun.dagui    = false;
                            phieun.bixoa    = false;
                        }
                        db.pdnas.InsertOnSubmit(phieun);
                        db.SubmitChanges();
                        Session["bp"]        = bophan;
                        Session["bophan"]    = bp;
                        Session["loaiP"]     = loaiP;
                        Session["loaiphieu"] = loaiphieu;
                        Session["maphieu"]   = maphieu;

                        Session["noidung"] = noidung;
                        Session["ngaytao"] = ngaythang;
                        Session["tieude"]  = tieude;
                        Response.Redirect("FrmViewCB.aspx");
                    }
                }
                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;
                            }
                            else if (ngonngu == "lbl_TW")
                            {
                                lbthongbao.Text = "该用户不属于部门 " + bd.DepName;
                            }
                            else if (ngonngu == "lbl_EN")
                            {
                                lbthongbao.Text = "The user does not belong to the department" + bd.DepName;
                            }
                        }
                        else
                        {
                            pdna phieun = new pdna();
                            {
                                phieun.pdno = maphieu;

                                phieun.GSBH     = macongty;
                                phieun.pdno     = maphieu;
                                phieun.Abtype   = loaiphieu;
                                phieun.pddepid  = bophan;
                                phieun.mytitle  = tieude;
                                phieun.pdmemovn = noidung;
                                phieun.CFMDate0 = DateTime.Parse(ngaythang);
                                phieun.CFMID0   = user;
                                phieun.USERID   = user;
                                phieun.dagui    = false;
                                phieun.bixoa    = false;
                            }
                            db.pdnas.InsertOnSubmit(phieun);
                            db.SubmitChanges();
                            Session["bp"]        = bophan;
                            Session["bophan"]    = bp;
                            Session["loaiP"]     = loaiP;
                            Session["loaiphieu"] = loaiphieu;
                            Session["maphieu"]   = maphieu;

                            Session["noidung"] = noidung;
                            Session["ngaytao"] = ngaythang;
                            Session["tieude"]  = tieude;
                            Response.Redirect("FrmViewCB.aspx");
                        }

                        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.pdno = maphieu;

                            phieun.GSBH     = macongty;
                            phieun.pdno     = maphieu;
                            phieun.Abtype   = loaiphieu;
                            phieun.pddepid  = bophan;
                            phieun.mytitle  = tieude;
                            phieun.pdmemovn = noidung;
                            phieun.CFMDate0 = DateTime.Parse(ngaythang);
                            phieun.CFMID0   = user;
                            phieun.USERID   = user;
                            phieun.dagui    = false;
                            phieun.bixoa    = false;
                            phieun.YN       = 6;
                        }
                        db.pdnas.InsertOnSubmit(phieun);
                        db.SubmitChanges();
                        Session["bp"]        = bophan;
                        Session["bophan"]    = bp;
                        Session["loaiP"]     = loaiP;
                        Session["loaiphieu"] = loaiphieu;
                        Session["maphieu"]   = maphieu;

                        Session["noidung"] = noidung;
                        Session["ngaytao"] = ngaythang;
                        Session["tieude"]  = tieude;
                        Response.Redirect("FrmViewCB.aspx");
                    }
                }
            }
            else
            {
                Response.Redirect("FrmViewCB.aspx");
            }
        }