예제 #1
0
파일: DAL_DieuXe.cs 프로젝트: ovitan/VB1
        ///////////////////////////////////////////////////////////////////CODE DIEU XE GIAO DIEN TTDieuXe//////////////////////////////////////////////////////////////
        public bool Delete_Dieu_Xe(DTO_DieuXe dxx)
        {
            string    check = "select * from dm_bang_ke where ma_dieu_xe='" + dxx.ma_dieu_xe.Trim() + "'";
            DataTable dtt   = data.ExcuteDataTable(check, null);

            if (dtt != null && dtt.Rows.Count > 0)
            {
                return(false);
            }
            string update_xe = "Update dm_xe set ma_tinh_trang=1 where ma_so_xe in (select ma_so_xe from dm_dieu_xe where ma_dieu_xe =@ma_dieu_xe) ";

            SqlParameter[] prs1 =
            {
                new SqlParameter("@ma_dieu_xe", dxx.ma_dieu_xe.Trim())
            };
            if (data.ExcuteNonQuery(update_xe, prs1) == true)
            {
                string         sql  = "delete from dm_dieu_xe where ma_dieu_xe =@ma_dieu_xe ";
                SqlParameter[] prs2 =
                {
                    new SqlParameter("@ma_dieu_xe", dxx.ma_dieu_xe.Trim())
                };

                return(data.ExcuteNonQuery(sql, prs2));
            }
            return(false);
        }
예제 #2
0
파일: DAL_DieuXe.cs 프로젝트: ovitan/VB1
        public List <DTO_DieuXe> _List_Get_Dieu_Xe_By_KhachHang_HopDong(DTO_DieuXe dxx)
        {
            string    sql = "select ma_hop_dong,trong_luong,ma_dieu_xe,A.ma_so_xe,so_tan,A.ma_khach_hang,noi_giao,noi_nhan,ngay_dieu_xe,ngay_ve,dia_chi,fax,B.ngay_tao, B.ten_khach_hang,case tinh_trang_thanh_toan when 0 then N'Chưa Thanh Toán' when 1 then N'Đã Thanh Toán' end as 'tinh_trang_thanh_toan' from dm_dieu_xe A join dm_khach_hang B on A.ma_khach_hang = B.ma_khach_hang and ma_hop_dong='" + dxx.ma_hop_dong.Trim() + "' , dm_xe where dm_xe.ma_so_xe=A.ma_so_xe  order by ma_dieu_xe desc,trong_luong desc";
            DataTable dt  = data.ExcuteDataTable(sql, null);

            if (dt != null && dt.Rows.Count > 0)
            {
                List <DTO_DieuXe> dxe = new List <DTO_DieuXe>();
                foreach (DataRow dr in dt.Rows)
                {
                    DTO_DieuXe xx = new DTO_DieuXe();
                    xx.ma_hop_dong   = dr["ma_hop_dong"].ToString();
                    xx.ma_dieu_xe    = dr["ma_dieu_xe"].ToString();
                    xx.so_tan        = dr["so_tan"].ToString();
                    xx.ma_khach_hang = dr["ma_khach_hang"].ToString();
                    xx.noi_giao      = dr["noi_giao"].ToString();
                    xx.noi_nhan      = dr["noi_nhan"].ToString();
                    xx.ngay_dieu_xe  = Convert.ToDateTime(dr["ngay_dieu_xe"].ToString());
                    if (dr["ngay_ve"].ToString() != "")
                    {
                        xx.ngay_ve = Convert.ToDateTime(dr["ngay_ve"].ToString());
                    }
                    xx.ma_so_xe              = dr["ma_so_xe"].ToString();
                    xx.ten_khach_hang        = dr["ten_khach_hang"].ToString();
                    xx.tinh_trang_thanh_toan = dr["tinh_trang_thanh_toan"].ToString();
                    xx.tai_trong_xe          = float.Parse(dr["trong_luong"].ToString());
                    dxe.Add(xx);
                }
                return(dxe);
            }
            return(null);
        }
예제 #3
0
 private void cbmadieuxe_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (cbmadieuxe.Text.Trim() != "" && txtmakhachhang.Text.Trim() != "")
     {
         DTO_DieuXe _xe = new DTO_DieuXe();
         _xe.ma_khach_hang = txtmakhachhang.Text;
         if (new BLL_BangKe()._List_Ma_Dieu_Xe(_xe) != null)
         {
             foreach (DTO_DieuXe dx in new BLL_BangKe()._List_Ma_Dieu_Xe(_xe))
             {
                 if (dx.ma_dieu_xe.Trim() == cbmadieuxe.Text.Trim())
                 {
                     txtmasoxe.Text         = dx.ma_so_xe.Trim();
                     txtnoinhan.Text        = dx.noi_nhan;
                     txtnoigiao.Text        = dx.noi_giao;
                     dtpngayvanchuyen.Value = dx.ngay_dieu_xe;
                     txtkhoiluong.Text      = dx.so_tan;
                     txtdongiachuyen.Text   = dx.don_gia_chuyen.ToString();
                     txtdongiatan.Text      = dx.don_gia_tan.ToString();
                 }
             }
         }
     }
     else
     {
         reset_control();
     }
 }
예제 #4
0
        private void _Load_ComBobox_Dieu_xe()
        {
            DTO_DieuXe dx = new DTO_DieuXe();

            dx.ma_khach_hang         = txtmakhachhang.Text.Trim();
            cbmadieuxe.DataSource    = new BLL_BangKe()._List_Ma_Dieu_Xe(dx);
            cbmadieuxe.DisplayMember = "ma_dieu_xe";
            cbmadieuxe.ValueMember   = "ma_so_xe";
        }
예제 #5
0
파일: frmTTDieuXe.cs 프로젝트: ovitan/VB1
 private void cbnoinhan_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (cbnoinhan.Text.Trim() != "")
     {
         DTO_DieuXe xx = new DTO_DieuXe();
         xx.noi_nhan = cbnoinhan.Text.Trim();
         _load_cb_noi_giao(xx);
     }
 }
예제 #6
0
파일: frmTTDieuXe.cs 프로젝트: ovitan/VB1
 private void btnsua_Click(object sender, EventArgs e)
 {
     foreach (ListViewItem item in lvthongtindieuxe.Items)
     {
         if (item.Selected)
         {
             DialogResult kq = MessageBox.Show("Bán Muốn Sửa Mã Điều Xe : " + item.SubItems[9].Text.Trim() + " - Có Mã Số Xe : " + item.SubItems[1].Text.Trim(), "Thông Báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
             if (kq == DialogResult.Yes)
             {
                 string message = "";
                 if (cbkhachhang.Text.Trim() == "")
                 {
                     message += " Chưa Chọn Khách Hàng ";
                 }
                 if (cbhopdong.Text.Trim() == "")
                 {
                     message += (string.IsNullOrEmpty(message) ? " " : " - ") + "Chưa Chọn Mã Hợp Đồng ";
                 }
                 if (txtmadieuxe.Text.Trim() == "")
                 {
                     message += (string.IsNullOrEmpty(message) ? " " : " - ") + "Chưa Có Mã Điều Xe";
                 }
                 if (dtpngayve.Value < dtpngaydi.Value)
                 {
                     message += (string.IsNullOrEmpty(message) ? " " : " - ") + "Ngày Về Không Hơp Lý.Vui Lòng Kiểm Tra Lại.";
                 }
                 if (message == "")
                 {
                     DTO_DieuXe dx = new DTO_DieuXe();
                     dx.ma_dieu_xe    = txtmadieuxe.Text.Trim();
                     dx.ma_khach_hang = Convert.ToString(cbkhachhang.SelectedValue.ToString());
                     dx.ngay_ve       = dtpngayve.Value;
                     dx.tttt          = int.Parse(cbtinhtrangthanhtoan.SelectedValue.ToString());
                     dx.ma_hop_dong   = cbhopdong.Text.Trim();
                     dx.noi_giao      = cbnoigiao.Text.Trim();
                     dx.noi_nhan      = cbnoinhan.Text.Trim();
                     dx.so_tan        = txtsotan.Text.Trim();
                     dx.ngay_dieu_xe  = dtpngaydi.Value;
                     dx.ma_so_xe      = item.SubItems[1].Text.Trim();
                     bool update = new BLL_DieuXe().Update_Dieu_Xe(dx);
                     if (update == true)
                     {
                         _Load_List_View_Dieu_Xe(cbhopdong.Text.Trim());
                         _list_view_xe();
                     }
                 }
                 if (message != "")
                 {
                     MessageBox.Show(message, "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
             }
         }
     }
 }
예제 #7
0
파일: DAL_DieuXe.cs 프로젝트: ovitan/VB1
        public float _Get_Tong_Trong_Luong(DTO_DieuXe dxx)
        {
            float     tong_tan = 0;
            string    sql      = "select sum(so_tan) as so_tan from dm_dieu_xe where ma_dieu_xe='" + dxx.ma_dieu_xe.Trim() + "'";
            DataTable dt       = data.ExcuteDataTable(sql, null);

            if (dt != null && dt.Rows.Count > 0)
            {
                tong_tan = float.Parse("0" + dt.Rows[0][0].ToString());
            }
            return(tong_tan);
        }
예제 #8
0
파일: DAL_DieuXe.cs 프로젝트: ovitan/VB1
        public List <DTO_DieuXe> _List_Get_NoiGiao(DTO_DieuXe dxx)
        {
            string    sql = "select distinct noi_giao from dm_bang_bao_gia where noi_nhan=N'" + dxx.noi_nhan.Trim() + "'";
            DataTable dt  = data.ExcuteDataTable(sql, null);

            if (dt != null && dt.Rows.Count > 0)
            {
                List <DTO_DieuXe> xx = new List <DTO_DieuXe>();
                foreach (DataRow dr in dt.Rows)
                {
                    DTO_DieuXe dxe = new DTO_DieuXe();
                    dxe.noi_giao = dr["noi_giao"].ToString();
                    xx.Add(dxe);
                }
                return(xx);
            }
            return(null);
        }
예제 #9
0
파일: frmTTDieuXe.cs 프로젝트: ovitan/VB1
 private void lvthongtindieuxe_SelectedIndexChanged(object sender, EventArgs e)
 {
     foreach (ListViewItem item in lvthongtindieuxe.Items)
     {
         if (item.Selected)
         {
             txtmadieuxe.Text = item.SubItems[9].Text.Trim();
             dtpngaydi.Value  = Convert.ToDateTime(item.SubItems[6].Text);
             if (item.SubItems[7].Text.Trim() != "")
             {
                 dtpngayve.Value = Convert.ToDateTime(item.SubItems[7].Text);
             }
             cbtinhtrangthanhtoan.SelectedValue = item.SubItems[8].Text.Trim() == "Chưa Thanh Toán" ? 0 : 1;
             DTO_DieuXe dv = new DTO_DieuXe();
             dv.ma_dieu_xe = item.SubItems[9].Text.Trim();
             txtsotan.Text = new BLL_DieuXe()._Get_Tong_Trong_Luong(dv).ToString();
         }
     }
 }
예제 #10
0
파일: frmTTDieuXe.cs 프로젝트: ovitan/VB1
 private void btnxoa_Click(object sender, EventArgs e)
 {
     foreach (ListViewItem item in lvthongtindieuxe.Items)
     {
         if (item.Selected)
         {
             DialogResult kq = MessageBox.Show("Bán Muốn Xóa Mã Điều Xe :" + item.SubItems[9].Text.Trim(), "Thông Báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
             if (kq == DialogResult.Yes)
             {
                 DTO_DieuXe dx = new DTO_DieuXe();
                 dx.ma_dieu_xe = item.SubItems[9].Text.Trim();
                 bool delete = new BLL_DieuXe().Delete_Dieu_Xe(dx);
                 if (delete == true)
                 {
                     _Load_List_View_Dieu_Xe(cbhopdong.Text.Trim());
                     _list_view_xe();
                 }
             }
         }
     }
 }
예제 #11
0
        public DTO_DieuXe[] _List_Ma_Dieu_Xe(DTO_DieuXe _xe)
        {
            //string sql = "select ma_dieu_xe,ma_so_xe,dm_dieu_xe.noi_nhan,dm_dieu_xe.noi_giao,so_tan,ngay_dieu_xe,don_gia_tan,don_gia_chuyen from dm_dieu_xe,dm_bang_bao_gia where ma_khach_hang=@mkh and dm_bang_bao_gia.noi_nhan=dm_dieu_xe.noi_nhan and dm_bang_bao_gia.noi_giao=dm_dieu_xe.noi_giao and ngay_ve is not NULL and tinh_trang_thanh_toan=0 and ma_dieu_xe not in (select distinct ma_dieu_xe from dm_bang_ke where dm_bang_ke.ma_khach_hang=@mkh ) "; //and ngay_ve=NULL and tinh_trang_thanh_toan=NULL;
            string sql = "select distinct ma_dieu_xe,dm_dieu_xe.noi_nhan,dm_dieu_xe.noi_giao,sum(so_tan) as so_tan,ngay_dieu_xe,don_gia_tan,don_gia_chuyen "
                         + "from dm_dieu_xe,dm_bang_bao_gia "
                         + "where ma_khach_hang=@mkh and dm_bang_bao_gia.noi_nhan=dm_dieu_xe.noi_nhan and dm_bang_bao_gia.noi_giao=dm_dieu_xe.noi_giao "
                         + "and ngay_ve is not NULL and tinh_trang_thanh_toan=0 and ma_dieu_xe  "
                         + "not in (select distinct ma_dieu_xe from dm_bang_ke where dm_bang_ke.ma_khach_hang=@mkh ) "
                         + "group by ma_dieu_xe,dm_dieu_xe.noi_nhan,dm_dieu_xe.noi_giao,ngay_dieu_xe,don_gia_tan,don_gia_chuyen ";

            SqlParameter[] prs =
            {
                new SqlParameter("@mkh", _xe.ma_khach_hang.Trim())
            };
            DataTable dt = data.ExcuteDataTable(sql, prs);

            if (dt.Rows.Count > 0)
            {
                DTO_DieuXe[] _xx = new DTO_DieuXe[dt.Rows.Count];
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    _xx[i]            = new DTO_DieuXe();
                    _xx[i].ma_dieu_xe = dt.Rows[i]["ma_dieu_xe"].ToString();
                    string    msx = "select ma_so_xe from dm_dieu_xe,dm_bang_bao_gia where ma_khach_hang='" + _xe.ma_khach_hang.Trim() + "' and dm_bang_bao_gia.noi_nhan=dm_dieu_xe.noi_nhan and dm_bang_bao_gia.noi_giao=dm_dieu_xe.noi_giao and ngay_ve is not NULL and tinh_trang_thanh_toan=0 and ma_dieu_xe='" + _xx[i].ma_dieu_xe.Trim() + "'";
                    DataTable dtt = data.ExcuteDataTable(msx, null);
                    foreach (DataRow dr in dtt.Rows)
                    {
                        _xx[i].ma_so_xe += dr["ma_so_xe"].ToString().Trim() + " ; ";
                    }
                    _xx[i].noi_nhan       = dt.Rows[i]["noi_nhan"].ToString();
                    _xx[i].noi_giao       = dt.Rows[i]["noi_giao"].ToString();
                    _xx[i].so_tan         = float.Parse(dt.Rows[i]["so_tan"].ToString()).ToString();
                    _xx[i].ngay_dieu_xe   = Convert.ToDateTime(dt.Rows[i]["ngay_dieu_xe"].ToString());
                    _xx[i].don_gia_tan    = float.Parse(dt.Rows[i]["don_gia_tan"].ToString());
                    _xx[i].don_gia_chuyen = float.Parse(dt.Rows[i]["don_gia_chuyen"].ToString());
                }
                return(_xx);
            }
            return(null);
        }
예제 #12
0
파일: DAL_DieuXe.cs 프로젝트: ovitan/VB1
        public bool Create_DX(DTO_DieuXe DX)
        {
            string sql = "insert into dm_dieu_xe(ma_hop_dong,ma_dieu_xe,ma_so_xe,ma_khach_hang,noi_giao,noi_nhan,so_tan,ngay_dieu_xe,tinh_trang_thanh_toan) values(@ma_hop_dong,@ma_dieu_xe,@ma_so_xe,@ma_khach_hang,@noi_giao,@noi_nhan,@so_tan,@ngay_dieu_xe,0)";

            SqlParameter[] prs =
            {
                new SqlParameter("@ma_hop_dong",   DX.ma_hop_dong.Trim()),
                new SqlParameter("@ma_dieu_xe",    DX.ma_dieu_xe.Trim()),
                new SqlParameter("@ma_so_xe",      DX.ma_so_xe.Trim()),
                new SqlParameter("@ma_khach_hang", DX.ma_khach_hang.Trim()),
                new SqlParameter("@noi_giao",      DX.noi_giao.Trim()),
                new SqlParameter("@noi_nhan",      DX.noi_nhan.Trim()),
                new SqlParameter("@ngay_dieu_xe",  DX.ngay_dieu_xe),
                new SqlParameter("@so_tan",        DX.so_tan),
            };
            if (data.ExcuteNonQuery(sql, prs) == true)
            {
                string Update = "Update dm_xe set ma_tinh_trang=2 where ma_so_xe='" + DX.ma_so_xe.Trim() + "' ";
                data.ExcuteNonQuery(Update, null);
            }
            return(true);
        }
예제 #13
0
파일: frmTTDieuXe.cs 프로젝트: ovitan/VB1
 private void _Load_List_View_Dieu_Xe(string mahopdong)
 {
     if (cbhopdong.Text.Trim() != "")
     {
         lvthongtindieuxe.Items.Clear();
         lvthongtindieuxe.Groups.Clear();
         DTO_DieuXe xxx = new DTO_DieuXe();
         xxx.ma_hop_dong = mahopdong;
         if (new BLL_DieuXe()._List_Get_Dieu_Xe_By_KhachHang_HopDong(xxx) != null)
         {
             foreach (DTO_DieuXe dx in new BLL_DieuXe()._List_Get_Dieu_Xe_By_KhachHang_HopDong(xxx))
             {
                 ListViewItem item = new ListViewItem(new string[]
                 {
                     "", dx.ma_so_xe, dx.tai_trong_xe.ToString(), dx.noi_nhan, dx.noi_giao, dx.so_tan, dx.ngay_dieu_xe.ToShortDateString(), dx.ngay_ve.ToShortDateString() == "01/01/0001"?"":dx.ngay_ve.ToShortDateString(), dx.tinh_trang_thanh_toan, dx.ma_dieu_xe
                 });
                 GroupItem(item);
                 this.lvthongtindieuxe.Items.Add(item);
             }
         }
     }
 }
예제 #14
0
파일: DAL_DieuXe.cs 프로젝트: ovitan/VB1
        public bool Update_DX(DTO_DieuXe DXE)
        {
            string sql = "update dm_dieu_xe set ngay_ve=@ngay_ve,tinh_trang_thanh_toan=@tinh_trang_thanh_toan, ma_so_xe=@ma_so_xe,ma_khach_hang=@ma_khach_hang,noi_giao=@noi_giao,noi_nhan=@noi_nhan,so_tan=@so_tan,ngay_dieu_xe=@ngay_dieu_xe where ma_dieu_xe=@ma_dieu_xe";

            SqlParameter[] prs =
            {
                new SqlParameter("@ma_dieu_xe",            DXE.ma_dieu_xe),
                new SqlParameter("@ma_so_xe",              DXE.ma_so_xe),
                new SqlParameter("@ma_khach_hang",         DXE.ma_khach_hang),
                new SqlParameter("@noi_giao",              DXE.noi_giao),
                new SqlParameter("@noi_nhan",              DXE.noi_nhan),
                new SqlParameter("@ngay_dieu_xe",          DXE.ngay_dieu_xe),
                new SqlParameter("@so_tan",                DXE.so_tan),
                new SqlParameter("@ngay_ve",               DXE.ngay_ve),
                new SqlParameter("@tinh_trang_thanh_toan", DXE.tttt)
            };
            if (data.ExcuteNonQuery(sql, prs) == true)
            {
                string Update = "Update dm_xe set ma_tinh_trang=1 where ma_so_xe='" + DXE.ma_so_xe.Trim() + "' ";
                data.ExcuteNonQuery(Update, null);
            }
            return(true);
        }
예제 #15
0
파일: frmDieuXe.cs 프로젝트: ovitan/VB1
        private void btn_luu_Click(object sender, EventArgs e)
        {
            if (!CheckBeforeSave())
            {
                return;
            }
            DTO_DieuXe dx = new DTO_DieuXe();

            dx.ma_dieu_xe    = txt_madieuxe.Text;
            dx.ma_khach_hang = Convert.ToString(cbb_khachhang.SelectedValue.ToString());
            dx.ma_so_xe      = Convert.ToString(cbb_soxe.SelectedValue);
            dx.so_tan        = txt_sotan.Text;
            dx.noi_giao      = txt_noigiao.Text;
            dx.noi_nhan      = txt_noinhan.Text;
            dx.ngay_dieu_xe  = data_ngaydieuxe.Value;
            dx.ngay_ve       = dtpngayve.Value;
            dx.tttt          = int.Parse(cbtinhtrangthanhtoan.SelectedValue.ToString());
            if (txt_madieuxe.Enabled)
            {
                dal_dx.Create_DX(dx);
            }
            else
            {
                dal_dx.Update_DX(dx);
            }
            BinbDataGridView_Dieuxe();
            if ((int.Parse(txt_sotan.Text) > int.Parse(txt_trongluongxe.Text)) && (int.Parse(txt_sotan.Text) - int.Parse(txt_trongluongxe.Text) > 0))
            {
                MessageBox.Show("Điều Thêm Xe " + (int.Parse(txt_sotan.Text) - int.Parse(txt_trongluongxe.Text)).ToString() + " Tấn", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            ResetControl();


            btn_xoa.Enabled = false;
            btn_sua.Enabled = false;
        }
예제 #16
0
파일: frmDieuXe.cs 프로젝트: ovitan/VB1
        private void grv_dieuxe_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            int i = e.RowIndex;

            if (e.RowIndex < 0)
            {
                return;
            }
            //if (e.RowIndex == grv_nhan_vien.Rows.Count-1)
            //    return;
            DTO_DieuXe dieuxe = grv_dieuxe.Rows[e.RowIndex].DataBoundItem as DTO_DieuXe;

            txt_madieuxe.Text           = dieuxe.ma_dieu_xe;
            txt_noigiao.Text            = dieuxe.noi_giao;
            txt_noinhan.Text            = dieuxe.noi_nhan;
            txt_sotan.Text              = dieuxe.so_tan;
            cbb_khachhang.SelectedValue = dieuxe.ma_khach_hang.Trim();
            //cbb_soxe.SelectedValue = dieuxe.ma_so_xe.Trim();
            cbb_soxe.Text = grv_dieuxe.Rows[i].Cells["col_sx"].Value.ToString();
            // cbb_soxe.SelectedIndex = 3;
            // MessageBox.Show(dieuxe.ma_so_xe.Trim());
            data_ngaydieuxe.Value = Convert.ToDateTime(dieuxe.ngay_dieu_xe);
            if (grv_dieuxe.Rows[i].Cells["ngay_ve"].Value.ToString().Trim() != "01/01/0001 12:00:00 SA")
            {
                dtpngayve.Value = Convert.ToDateTime(dieuxe.ngay_ve);
                //MessageBox.Show(grv_dieuxe.Rows[i].Cells["ngay_ve"].Value.ToString() );
            }
            ;
            cbtinhtrangthanhtoan.SelectedValue = dieuxe.tinh_trang_thanh_toan == "Chưa Thanh Toán" ? 0 : 1;
            EnableControl(false);
            MethodHelper.ClearErrorProvider();

            btn_luu.Enabled = false;
            btn_sua.Enabled = true;
            btn_xoa.Enabled = true;
        }
예제 #17
0
파일: BLL_DieuXe.cs 프로젝트: ovitan/VB1
 public bool Create_DX(DTO_DieuXe DX)
 {
     return(dx.Create_DX(DX));
 }
예제 #18
0
파일: frmTTDieuXe.cs 프로젝트: ovitan/VB1
        private void _Them_Dieu_Xe()
        {
            string message = "";

            if (cbkhachhang.Text.Trim() == "")
            {
                message += " Chưa Chọn Khách Hàng ";
            }
            if (cbhopdong.Text.Trim() == "")
            {
                message += (string.IsNullOrEmpty(message) ? " " : " - ") + "Chưa Chọn Mã Hợp Đồng ";
            }
            if (txtmadieuxe.Text.Trim() == "")
            {
                message += (string.IsNullOrEmpty(message) ? " " : " - ") + "Chưa Có Mã Điều Xe";
            }
            if (txtsotan.Text.Trim() == "")
            {
                message += (string.IsNullOrEmpty(message) ? " " : " - ") + "Chưa Nhập Khối Lượng ";
            }
            if (cbnoinhan.Text.Trim() == "")
            {
                message += (string.IsNullOrEmpty(message) ? " " : " - ") + "Chưa Chọn Nơi Nhận ";
            }
            if (cbnoigiao.Text.Trim() == "")
            {
                message += (string.IsNullOrEmpty(message) ? " " : " - ") + "Chưa Chọn Nơi Giao ";
            }
            int   stt       = 0;
            bool  sosanh    = true;
            float _tong_tan = 0;

            foreach (ListViewItem item in lvxe.Items)
            {
                if (item.Checked)
                {
                    stt++;
                    _tong_tan += float.Parse(item.SubItems[2].Text);
                }
            }
            if (_tong_tan < float.Parse("0" + txtsotan.Text.Trim()))
            {
                sosanh = false;
            }
            if (stt == 0)
            {
                message += (string.IsNullOrEmpty(message) ? " " : " - ") + "Chưa Chọn Xe ";
            }
            if (sosanh == false && stt != 0)
            {
                message += (string.IsNullOrEmpty(message) ? " " : " - ") + "Có Số Lượng Xe Điều Đi Không Đủ ";
            }
            if (message == "")
            {
                DTO_DieuXe dx = new DTO_DieuXe();
                dx.ma_dieu_xe    = txtmadieuxe.Text.Trim();
                dx.ma_khach_hang = Convert.ToString(cbkhachhang.SelectedValue.ToString());
                dx.ngay_ve       = dtpngayve.Value;
                dx.tttt          = int.Parse(cbtinhtrangthanhtoan.SelectedValue.ToString());
                dx.ma_hop_dong   = cbhopdong.Text.Trim();
                dx.noi_giao      = cbnoigiao.Text.Trim();
                dx.noi_nhan      = cbnoinhan.Text.Trim();
                dx.ngay_dieu_xe  = dtpngaydi.Value;
                bool  kq             = true;
                float so_tan_con_lai = float.Parse(txtsotan.Text.Trim());
                while (so_tan_con_lai > 0)
                {
                    foreach (ListViewItem item in lvxe.Items)
                    {
                        if (item.Checked)
                        {
                            if (so_tan_con_lai > float.Parse(item.SubItems[2].Text))
                            {
                                dx.so_tan = item.SubItems[2].Text;
                            }
                            else
                            {
                                dx.so_tan = (so_tan_con_lai < float.Parse(item.SubItems[2].Text)) ? so_tan_con_lai.ToString() : (so_tan_con_lai - float.Parse(item.SubItems[2].Text)).ToString();
                            }
                            so_tan_con_lai = so_tan_con_lai - float.Parse(item.SubItems[2].Text);
                            dx.ma_so_xe    = Convert.ToString(item.SubItems[1].Text);
                            kq             = new BLL_DieuXe().Create_DX(dx);
                        }
                        if (so_tan_con_lai <= 0)
                        {
                            break;
                        }
                    }
                }
                if (kq == false)
                {
                    message = " Lưu Điều Xe Thất Bại ";
                    MessageBox.Show(message + "!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    _list_view_xe();
                    _Load_List_View_Dieu_Xe(cbhopdong.Text.Trim());
                    txtmadieuxe.Text = new BLL_DieuXe()._Ma_Dieu_Xe_Moi();
                }
            }
            else
            {
                MessageBox.Show("Bạn" + message + "!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
예제 #19
0
파일: frmTTDieuXe.cs 프로젝트: ovitan/VB1
 private void _load_cb_noi_giao(DTO_DieuXe xx)
 {
     cbnoigiao.DataSource    = new BLL_DieuXe()._List_Get_NoiGiao(xx);
     cbnoigiao.DisplayMember = "noi_giao";
     cbnoigiao.ValueMember   = "noi_giao";
 }
예제 #20
0
파일: BLL_DieuXe.cs 프로젝트: ovitan/VB1
 public bool Update_Dieu_Xe(DTO_DieuXe DXE)
 {
     return(dx.Update_Dieu_Xe(DXE));
 }
예제 #21
0
파일: BLL_DieuXe.cs 프로젝트: ovitan/VB1
 public float _Get_Tong_Trong_Luong(DTO_DieuXe dxx)
 {
     return(dx._Get_Tong_Trong_Luong(dxx));
 }
예제 #22
0
파일: BLL_DieuXe.cs 프로젝트: ovitan/VB1
 public bool Delete_Dieu_Xe(DTO_DieuXe dxx)
 {
     return(dx.Delete_Dieu_Xe(dxx));
 }
예제 #23
0
파일: BLL_DieuXe.cs 프로젝트: ovitan/VB1
 public List <DTO_DieuXe> _List_Get_Dieu_Xe_By_KhachHang_HopDong(DTO_DieuXe dxx)
 {
     return(dx._List_Get_Dieu_Xe_By_KhachHang_HopDong(dxx));
 }
예제 #24
0
파일: BLL_DieuXe.cs 프로젝트: ovitan/VB1
 public List <DTO_DieuXe> _List_Get_NoiGiao(DTO_DieuXe dxx)
 {
     return(dx._List_Get_NoiGiao(dxx));
 }
예제 #25
0
파일: BLL_BangKe.cs 프로젝트: ovitan/VB1
 public DTO_DieuXe[] _List_Ma_Dieu_Xe(DTO_DieuXe _xe)
 {
     return(new DAL_BangKe()._List_Ma_Dieu_Xe(_xe));
 }