Example #1
0
        protected void btnThemPhieuXuatKhac_Click(object sender, EventArgs e)
        {
            if (cmbLyDoXuat.Text != "")
            {
                string    IDPhieuXuatKhac = IDPhieuXuatKhac_Temp.Value.ToString();
                DataTable db = data.LayDanhSachPhieuXuatKhac_Temp(IDPhieuXuatKhac);
                if (db.Rows.Count != 0)
                {
                    string   IDNguoiLapPhieu = Session["IDNhanVien"].ToString();
                    DateTime NgayLapPhieu    = DateTime.Parse(cmbNgayLapPhieu.Text.ToString());
                    string   IDLyDoXuat      = cmbLyDoXuat.Value.ToString();
                    string   GhiChu          = txtGhiChu == null ? "" : txtGhiChu.Text.ToString();
                    string   IDChiNhanh      = Session["IDChiNhanh"].ToString();
                    data = new dtPhieuXuatKhac();
                    object ID = data.ThemPhieuXuatKhac_Temp();
                    if (ID != null)
                    {
                        data.CapNhatPhieuXuatKhac_ID(ID, IDNguoiLapPhieu, IDLyDoXuat, NgayLapPhieu, GhiChu, IDChiNhanh);
                        foreach (DataRow dr in db.Rows)
                        {
                            string IDNguyenLieu = dr["IDNguyenLieu"].ToString();
                            string TonKho       = dr["TonKho"].ToString();
                            string IDDonViTinh  = dr["IDDonViTinh"].ToString();
                            string SoLuongXuat  = dr["SoLuongXuat"].ToString();
                            string MaNguyenLieu = dr["MaNguyenLieu"].ToString();
                            string DonGia       = dr["DonGia"].ToString();
                            string ThanhTien    = dr["ThanhTien"].ToString();
                            data = new dtPhieuXuatKhac();
                            data.ThemChiTietPhieuXuatKhac(ID, IDNguyenLieu, TonKho, IDDonViTinh, SoLuongXuat, MaNguyenLieu, DonGia, ThanhTien);

                            //dtLichSuKho.ThemLichSu(Session["IDChiNhanh"].ToString(), IDNguyenLieu, Session["IDNhanVien"].ToString(), dtLichSuKho.LaySoLuongTonKho(Session["IDChiNhanh"].ToString(), IDNguyenLieu), (Int32.Parse(dtLichSuKho.LaySoLuongTonKho(Session["IDChiNhanh"].ToString(), IDNguyenLieu)) - Int32.Parse(SoLuongXuat)) + "", "Phiếu xuất khác");

                            dtSetting.TruTonKho(IDNguyenLieu, SoLuongXuat, IDChiNhanh);
                        }
                        data = new dtPhieuXuatKhac();
                        data.XoaChiTietPhieuXuatKhac_Temp(IDPhieuXuatKhac);

                        dtLichSuTruyCap.ThemLichSu(Session["IDChiNhanh"].ToString(), Session["IDNhom"].ToString(), Session["IDNhanVien"].ToString(), "Phiếu xuất khác", "Thêm phiếu xuất khác");
                        Response.Redirect("DanhSachPhieuXuatKhac.aspx");
                    }
                }
                else
                {
                    cmbHangHoa.Focus();
                    Response.Write("<script language='JavaScript'> alert('Danh sách hàng hóa rỗng.'); </script>");
                }
            }
            else
            {
                cmbLyDoXuat.Focus();
                Response.Write("<script language='JavaScript'> alert('Vui lòng chọn lý do để xuất.'); </script>");
            }
        }
Example #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         data = new dtPhieuXuatKhac();
         object IDPhieuXuatKhac = data.ThemPhieuXuatKhac_Temp();
         IDPhieuXuatKhac_Temp.Value = IDPhieuXuatKhac.ToString();
         cmbChiNhanh.Text           = Session["IDChiNhanh"].ToString();
         txtNguoiLapPhieu.Text      = Session["TenDangNhap"].ToString();
     }
     LoadGrid(IDPhieuXuatKhac_Temp.Value.ToString());
 }
Example #3
0
 protected void btnThem_Click(object sender, EventArgs e)
 {
     if (cmbHangHoa.Value != null && txtSoLuong.Text != "")
     {
         float SoLuong = float.Parse(txtSoLuong.Value.ToString());
         if (SoLuong > 0)
         {
             float  SLTon           = float.Parse(txtTonKho.Text);
             string IDHangHoa       = cmbHangHoa.Value.ToString();
             string IDPhieuXuatKhac = IDPhieuXuatKhac_Temp.Value.ToString();
             string MaHang          = dtHangHoa.LayMaHang(IDHangHoa);
             string IDDonViTinh     = dtHangHoa.LayIDDonViTinh(IDHangHoa);
             string TonKho          = txtTonKho.Text.ToString();
             string GhiChuHH        = txtGhiChuHH.Text == null ? "" : txtGhiChuHH.Text.ToString();
             if (dtSetting.KT_ChuyenAm() == 0)
             {
                 if (SLTon < SoLuong)
                 {
                     txtSoLuong.Text = SLTon.ToString();
                     Response.Write("<script language='JavaScript'> alert('Hàng hóa tồn kho không đủ.'); </script>");
                 }
                 else
                 {
                     DataTable db = data.KTChiTietPhieuXuatKhac_Temp(IDHangHoa, IDPhieuXuatKhac);// kiểm tra hàng hóa
                     if (db.Rows.Count == 0)
                     {
                         data = new dtPhieuXuatKhac();
                         data.ThemPhieuXuatKhac_Temp(IDPhieuXuatKhac, MaHang, IDHangHoa, IDDonViTinh, TonKho, SoLuong.ToString(), GhiChuHH);
                         Clear();
                     }
                     else
                     {
                         data = new dtPhieuXuatKhac();
                         data.UpdatePhieuXuatKhac_temp(IDPhieuXuatKhac, IDHangHoa, SoLuong);
                         Clear();
                     }
                     LoadGrid(IDPhieuXuatKhac);
                 }
             }
             else
             {
                 DataTable db = data.KTChiTietPhieuXuatKhac_Temp(IDHangHoa, IDPhieuXuatKhac);// kiểm tra hàng hóa
                 if (db.Rows.Count == 0)
                 {
                     data = new dtPhieuXuatKhac();
                     data.ThemPhieuXuatKhac_Temp(IDPhieuXuatKhac, MaHang, IDHangHoa, IDDonViTinh, TonKho, SoLuong.ToString(), GhiChuHH);
                     Clear();
                 }
                 else
                 {
                     data = new dtPhieuXuatKhac();
                     data.UpdatePhieuXuatKhac_temp(IDPhieuXuatKhac, IDHangHoa, SoLuong);
                     Clear();
                 }
                 if (SLTon < SoLuong)
                 {
                     Response.Write("<script language='JavaScript'> alert('Số hàng tồn trong kho hiện tại không đủ.'); </script>");
                 }
                 LoadGrid(IDPhieuXuatKhac);
             }
         }
         else
         {
             Response.Write("<script language='JavaScript'> alert('Số Lượng phải > 0.'); </script>");
         }
     }
     else
     {
         Response.Write("<script language='JavaScript'> alert('Bạn chưa chọn hàng hóa.'); </script>");
     }
 }