Example #1
0
 private void cbb_soxe_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (cbb_soxe.SelectedValue != null)
     {
         string chonsoxe = cbb_soxe.SelectedValue.ToString().Trim();
         if (cbb_soxe.SelectedIndex == 0)
         {
             txt_trongluongxe.Text = "";
             grv_NV.DataSource     = dal_nv.dt_GetAll();
         }
         else
         {
             // int i = cbb_soxe.SelectedIndex;
             grv_NV.DataSource = null;
             grv_NV.DataSource = dal_nv.GetAll_NV_ID(chonsoxe);
             DTO_Xe dto = new DTO_Xe();
             dto.ma_so_xe = cbb_soxe.SelectedValue.ToString();
             List <DTO_Xe> li = new BLL_DieuXe().Get_TrongLuongXe(dto);
             foreach (DTO_Xe xe in li)
             {
                 txt_trongluongxe.Text = xe.trong_luong.ToString();
             }
             //txt_trongluongxe.Text = grv_TTxe.Rows[i].Cells["coltrongluong"].Value.ToString();
         }
     }
 }
Example #2
0
 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);
                 }
             }
         }
     }
 }
Example #3
0
 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();
                 }
             }
         }
     }
 }
Example #4
0
        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);
            }
        }