public List <CTDoiTra_DTO> LayChiTietPT(int IDDoiTra)
        {
            DataTable           data       = DataProvider.Instance.ExecuteQuery("TimKiemCTPT @IDPT", new object[] { IDDoiTra });
            List <CTDoiTra_DTO> DanhSachSP = new List <CTDoiTra_DTO>();

            foreach (DataRow item in data.Rows)
            {
                CTDoiTra_DTO hd = new CTDoiTra_DTO(item);
                DanhSachSP.Add(hd);
            }
            List <CTDoiTra_DTO> DanhSachSPMoi = new List <CTDoiTra_DTO>();

            foreach (CTDoiTra_DTO item in DanhSachSP)
            {
                string[] arrListIMEI = item.IMEI.Split(' ');
                string[] arrListLyDo = item.LyDo.Split('|');
                if (arrListLyDo.Length > 1)
                {
                    for (int i = 0; i < arrListLyDo.Length; i++)
                    {
                        CTDoiTra_DTO newItem = new CTDoiTra_DTO();
                        newItem.IDDoitra = item.IDDoitra;
                        newItem.IDHoaDon = item.IDHoaDon;
                        newItem.IDSP     = item.IDSP;
                        newItem.TenSP    = item.TenSP;
                        newItem.SoLuong  = 1;
                        newItem.Gia      = item.Gia;
                        newItem.IMEI     = arrListIMEI[i];
                        newItem.LyDo     = arrListLyDo[i];
                        DanhSachSPMoi.Add(newItem);
                    }
                }
                else
                {
                    DanhSachSPMoi.Add(item);
                }
            }
            return(DanhSachSPMoi);
        }
Пример #2
0
 private void btnThemSP_Click(object sender, EventArgs e)
 {
     if (txtLyDo.Text == "")
     {
         MessageBox.Show("Đổi trả thì phải có lí do chứ!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     if (cbIMEI.Text == "")
     {
         MessageBox.Show("Mã IMEI không tồn tại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     else
     {
         foreach (DataGridViewRow row in dtgvDSDT.Rows)
         {
             if (dtgvDSDT.Rows.Count > 1 && cbIMEI.SelectedValue.ToString().Equals(row.Cells["PDT_IMEI"].Value))
             {
                 //var a = row.Cells["PT_IMEI"].Value;
                 MessageBox.Show("Mã IMEI đã có trong danh sách đổi", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 return;
             }
         }
         CTDoiTra_DTO ChiTiet_DT = new CTDoiTra_DTO();
         ChiTiet_DT.IDHoaDon = Convert.ToInt32(txtIDHD.Text);
         ChiTiet_DT.IDSP     = Convert.ToInt32(txtMaSP.Text);
         ChiTiet_DT.TenSP    = txtTenSP.Text;
         ChiTiet_DT.Gia      = nmDonGia.Value;
         ChiTiet_DT.LyDo     = txtLyDo.Text;
         ChiTiet_DT.SoLuong  = 1;
         ChiTiet_DT.IMEI     = cbIMEI.SelectedValue.ToString();
         DanhSachPT.Add(ChiTiet_DT);
         listDT.Add(ChiTiet_DT);
         dtgvDSDT.DataSource = DanhSachPT;
     }
 }