Exemple #1
0
        public DTO_PhieuTra[] search_PhieuTra(string NgLap)
        {
            int       i         = 0;
            DataTable infotable = pt.timKiemPhieuTra(NgLap);

            if (infotable.Rows.Count == 0)
            {
                DTO_PhieuTra[] temp = new DTO_PhieuTra[1];
                temp[0] = new DTO_PhieuTra(getThongTinPT(0, 0), getThongTinPT(1, 0), getThongTinPT(2, 0), getThongTinPT(3, 0), getThongTinPT(4, 0), getThongTinPT(5, 0));
                return(temp);
            }
            DTO_PhieuTra[]    dtopt  = new DTO_PhieuTra[infotable.Rows.Count];
            DataRowCollection result = infotable.Rows;

            foreach (DataRow row in result)
            {
                string[] str = new string[8];
                for (int j = 0; j <= 5; j++)
                {
                    str[j] = row[j].ToString();
                }
                dtopt[i] = new DTO_PhieuTra(str[0], str[1], str[2], str[3], str[4], str[5]);
                i++;
            }
            return(dtopt);
        }
Exemple #2
0
        public bool suaPhieuTra(DTO_PhieuTra tv)
        {
            try
            {
                // Ket noi
                connect.Open();

                // Query string
                string SQL = string.Format("UPDATE PHIEUTRA " +
                                           "SET MAPT='{0}', MANCC= '{1}', NGNHAP='{2}',TONGSL= {3} , TONGTIEN={4} ,GHICHU= N'{5}'",
                                           tv.MAPT, tv.MANCC, tv.NGNHAP, tv.TONGSL, tv.TONGTIEN, tv.GHICHU);

                // Command (mặc định command type = text nên chúng ta khỏi fải làm gì nhiều).
                SqlCommand cmd = new SqlCommand(SQL, connect);

                // Query và kiểm tra
                if (cmd.ExecuteNonQuery() > 0)
                {
                    return(true);
                }
            }
            catch (Exception e)
            {
            }
            finally
            {
                // Dong ket noi
                connect.Close();
            }

            return(false);
        }
Exemple #3
0
        public bool themPhieuTra(DTO_PhieuTra tv)// THẮNG
        {
            try
            {
                // Ket noi
                connect.Open();


                string SQL = string.Format("INSERT INTO PHIEUTRA (MAPT, MANCC, NGNHAP, TONGSL,TONGTIEN, GHICHU) " +
                                           "VALUES ('{0}', '{1}', '{2}',{3}, {4}, N'{5}')",
                                           tv.MAPT, tv.MANCC, tv.NGNHAP, tv.TONGSL, tv.TONGTIEN, tv.GHICHU); // DỮ LIỆU NHẬP VÀO

                // Command (mặc định command type = text nên chúng ta khỏi fải làm gì nhiều).
                SqlCommand cmd = new SqlCommand(SQL, connect);

                // Query và kiểm tra
                if (cmd.ExecuteNonQuery() > 0)
                {
                    return(true);
                }
            }
            catch (Exception e)
            {
            }
            finally
            {
                // Dong ket noi
                connect.Close();
            }

            return(false);
        }
Exemple #4
0
        static public string check_Nhap(DTO_PhieuTra pt)
        {
            string error = "";

            Stelia_BUS.Stelia_BUS bus      = new Stelia_BUS.Stelia_BUS();
            DTO_PhieuTra[]        phieutra = bus.timkiem_PhieuTra(pt.MAPT);
            if (phieutra[0].MAPT == pt.MAPT)
            {
                error += "Phiếu trả này đã tồn tại";
            }
            return(error);
        }
        private void pictureBox3_Click(object sender, EventArgs e)
        {
            Stelia_BUS.Stelia_BUS bus = new Stelia_BUS.Stelia_BUS();
            if (dataGridView1.Rows.Count == 0)
            {
                PushNoti noti1 = new PushNoti("Error", "Chưa có chi tiết phiếu trả!");
                noti1.Width = this.Width;
                this.Controls.Add(noti1);
                noti1.Show();
                noti1.ShowNoti();
            }
            DTO_PhieuTra PT    = new DTO_PhieuTra(txtMaPT.Text, txtMaNCC.Text, DateChange.ToString(dateNgNhap.DateTime), "0", "0", richTextBox1.Text);
            string       error = CheckThongTin.check_Nhap(PT);

            if (error != "")
            {
                PushNoti noti1 = new PushNoti("Error", error);
                noti1.Width = this.Width;
                this.Controls.Add(noti1);
                noti1.Show();
                noti1.ShowNoti();
                return;
            }
            if (bus.themData(PT) == false)
            {
                PushNoti noti1 = new PushNoti("Error", "Thêm phiếu trả không thành công!");
                noti1.Width = this.Width;
                this.Controls.Add(noti1);
                noti1.Show();
                noti1.ShowNoti();
                return;
            }
            int SL = 0;
            int GT = 0;

            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                DTO_CTPhieuTra ctpn = new DTO_CTPhieuTra(PT.MAPT, row.Cells[0].Value.ToString(), row.Cells[2].Value.ToString(), row.Cells[3].Value.ToString());
                SL += int.Parse(row.Cells[2].Value.ToString());
                GT += int.Parse(row.Cells[3].Value.ToString());
                DTO_SanPham[] sp = bus.search_SANPHAM(row.Cells[0].Value.ToString());
                sp[0].SLUONG = (int.Parse(sp[0].SLUONG) - int.Parse(row.Cells[2].Value.ToString())).ToString();
                bus.suaData(sp[0]);
                bus.themData(ctpn);
            }
            PT.TONGSL   = SL.ToString();
            PT.TONGTIEN = GT.ToString();
            bus.suaData(PT);
            DialogResult = DialogResult.OK;
            Close();
        }
        public void ThemPhieuTra(DTO_PhieuTra DTO)
        {
            string    strSql   = "usp_ThemPhieuTra";
            DBConnect provider = new DBConnect();

            provider.Connect();

            provider.ExecuteNonQuery(CommandType.StoredProcedure, strSql,
                                     new SqlParameter {
                ParameterName = "@MaPhieuTra", Value = DTO.MaPhieuTra
            },
                                     new SqlParameter {
                ParameterName = "@MaNVLapPhieuTra", Value = DTO.MaNhanVienLapPhieuTra
            });
            provider.Disconnect();
        }
        public void ThemChiTietPhieuTra(DTO_PhieuTra DTO)
        {
            string    strSql   = "usp_ThemChiTietPhieuTra";
            DBConnect provider = new DBConnect();

            provider.Connect();

            provider.ExecuteNonQuery(CommandType.StoredProcedure, strSql,
                                     new SqlParameter {
                ParameterName = "@MaCTPT", Value = DTO.MaCTPT
            },
                                     new SqlParameter {
                ParameterName = "@MaPhieuTra", Value = DTO.MaPhieuTra
            },
                                     new SqlParameter {
                ParameterName = "@MaPhieuMuon", Value = DTO.MaPhieuMuon
            },
                                     new SqlParameter {
                ParameterName = "@MaTaiLieu", Value = DTO.MaTaiLieu
            });
            provider.Disconnect();
        }
Exemple #8
0
 public void ThemPhieuTra(DTO_PhieuTra DTO)
 {
     dal_PhieuTra.ThemPhieuTra(DTO);
 }
Exemple #9
0
 public void ThemChiTietPhieuTra(DTO_PhieuTra DTO)
 {
     dal_PhieuTra.ThemChiTietPhieuTra(DTO);
 }
Exemple #10
0
 public bool suaData(DTO_PhieuTra tv)
 {
     return(pt.suaPhieuTra(tv));
 }
Exemple #11
0
 public bool themData(DTO_PhieuTra tv)
 {
     return(pt.themPhieuTra(tv));
 }
Exemple #12
0
 public bool addPT(DTO_PhieuTra pt)
 {
     return(dalphieutra.AddPT(pt));
 }
Exemple #13
0
 public DataTable ChonSachMuon_Select(DTO_PhieuTra dl)
 {
     return(xl.table_Select("Select     ID_PhieuMuonSach, ID_TheDocGia, ID_Sach, Ten_NguoiMuon, NgayMuon, NgayHenTra, Sl_SachMuon, GhiChu, TrangThai_PhieuMuon from PhieuMuonSach order by ID_PhieuMuonSach desc"));
 }
Exemple #14
0
 public DataTable Sach_Select(DTO_PhieuTra dl)
 {
     return(xl.table_Select("select Distinct ID_Sach from PhieuMuonSach where ID_TheDocGia = " + dl.LayIDNguoiMuon + ""));
 }
Exemple #15
0
 public DataTable DocGia_Select(DTO_PhieuTra dl)
 {
     return(xl.table_Select("select Distinct ID_TheDocGia from PhieuMuonSach"));
 }