Ejemplo n.º 1
0
 public Entities.PhieuTTCuaKH[] PhieuTTCuaKH()
 {
     Entities.PhieuTTCuaKH[] pttckh1 = new BizLogic.PhieuTTCuaKH().Select();
     if (pttckh1 == null)
     {
         pttckh1 = new Entities.PhieuTTCuaKH[0];
     }
     return(pttckh1);
 }
Ejemplo n.º 2
0
        public void SelectPhieuTTCuaKH()
        {
            try
            {
                cl = new Server_Client.Client();
                // gán TCPclient
                this.client1 = cl.Connect(Luu.IP, Luu.Ports);
                // khởi tạo biến truyền vào với hàm khởi tạo
                Entities.PhieuTTCuaKH pttckh = new Entities.PhieuTTCuaKH();
                // truyền HanhDong
                pttckh = new Entities.PhieuTTCuaKH("Select");
                // khởi tạo mảng đối tượng để hứng giá trị
                Entities.PhieuTTCuaKH[] pttckh1 = new Entities.PhieuTTCuaKH[1];
                clientstrem = cl.SerializeObj(this.client1, "PhieuTTCuaKH", pttckh);
                // đổ mảng đối tượng vào datagripview
                pttckh1 = (Entities.PhieuTTCuaKH[])cl.DeserializeHepper1(clientstrem, pttckh1);
                if (pttckh1 == null)
                {
                    pttckh1 = new Entities.PhieuTTCuaKH[0];
                    pttkh   = new Entities.PhieuTTCuaKH[0];
                    return;
                }

                Entities.PhieuTTCuaKH[] pttkhTEM = new Entities.PhieuTTCuaKH[pttckh1.Length];
                int sotang = 0;
                for (int j = 0; j < pttckh1.Length; j++)
                {
                    if (pttckh1[j].Deleted == false)
                    {
                        pttkhTEM[sotang] = pttckh1[j];
                        sotang++;
                    }
                }

                pttkh = new Entities.PhieuTTCuaKH[sotang];
                if (sotang != 0)
                {
                    for (int j = 0; j < sotang; j++)
                    {
                        pttkh[j] = pttkhTEM[j];
                    }
                }
                else
                {
                    pttkh = new Entities.PhieuTTCuaKH[0];
                }
            }
            catch (Exception ex)
            {
                pttkh = new Entities.PhieuTTCuaKH[0];
            }
        }
 /// <summary>
 /// xử lý khi tìm kiếm
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void txttimkiem_TextChanged(object sender, EventArgs e)
 {
     try
     {
         if (rdbtimkiem3.Checked == true)
         {
             return;
         }
         if (txttimkiem.Text.Length == 0)
         {
             dtgvThanhtoanKH.DataSource = new Entities.PhieuTTCuaKH[0];
             return;
         }
         int soluong = 0;
         if (hienthi != null)
         {
             if (rdbtimkiem2.Checked == true)
             {
                 for (int i = 0; i < hienthi.Length; i++)
                 {
                     int kiemtra = hienthi[i].MaPhieuTTCuaKH.ToString().ToUpper().IndexOf(txttimkiem.Text.ToUpper());
                     if (kiemtra >= 0)
                     {
                         soluong++;
                     }
                 }
                 if (soluong == 0)
                 {
                     dtgvThanhtoanKH.DataSource = new Entities.PhieuTTCuaKH[0];
                     return;
                 }
                 Entities.PhieuTTCuaKH[] hienthitheoma = new Entities.PhieuTTCuaKH[soluong];
                 soluong = 0;
                 for (int i = 0; i < hienthi.Length; i++)
                 {
                     int kiemtra = hienthi[i].MaPhieuTTCuaKH.ToString().ToUpper().IndexOf(txttimkiem.Text.ToUpper());
                     if (kiemtra >= 0)
                     {
                         hienthitheoma[soluong] = hienthi[i];
                         soluong++;
                     }
                 }
                 dtgvThanhtoanKH.DataSource = hienthitheoma;
             }
         }
     }
     finally
     {
         fix();
     }
 }
        /// <summary>
        /// delete
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tsslxoa_Click(object sender, EventArgs e)
        {
            try
            {
                System.Windows.Forms.DialogResult giatri = System.Windows.Forms.MessageBox.Show("Bạn chắc chắn muốn Xóa không?", "Hệ Thống Cảnh Báo", System.Windows.Forms.MessageBoxButtons.YesNo);
                {
                    if (giatri == System.Windows.Forms.DialogResult.Yes)
                    {
                        bool ktdelete = false;
                        int  idcurent = int.Parse(dtgvThanhtoanKH.Rows[i].Cells["PhieuTTCuaKHID"].Value.ToString());
                        SelectData();
                        for (int j = 0; j < pttckh1.Length; j++)
                        {
                            if (pttckh1[j].Deleted == false)
                            {
                                if (pttckh1[j].PhieuTTCuaKHID == idcurent)
                                {
                                    ktdelete = true;
                                    break;
                                }
                            }
                        }
                        if (ktdelete == true)
                        {
                            cl           = new Server_Client.Client();
                            this.client1 = cl.Connect(Luu.IP, Luu.Ports);

                            Entities.PhieuTTCuaKH pt = new Entities.PhieuTTCuaKH();
                            pt = new Entities.PhieuTTCuaKH("Delete", idcurent);

                            clientstrem = cl.SerializeObj(this.client1, "PhieuTTCuaKH", pt);
                            bool kt = false;
                            kt = (bool)cl.DeserializeHepper(clientstrem, kt);
                            if (kt == true)
                            {
                                MessageBox.Show("Delete thanh cong");
                            }
                        }
                        else
                        {
                            MessageBox.Show("Hàng này đã bị xóa rồi");
                        }
                        SelectData();
                    }
                }
            }
            catch
            {
            }
        }
Ejemplo n.º 5
0
        private void SelectPhieuTTCuaKH()
        {
            try
            {
                if (phieuttcuakh == null || phieuttcuakh.Length == 0)
                {
                    phieuttcuakh = new Entities.PhieuTTCuaKH[0];
                    return;
                }

                Entities.PhieuTTCuaKH[] pt2 = new Entities.PhieuTTCuaKH[phieuttcuakh.Length];
                int sotang = 0;
                for (int j = 0; j < phieuttcuakh.Length; j++)
                {
                    DateTime hientai = phieuttcuakh[j].NgayLap;

                    if (phieuttcuakh[j].Deleted == false && hientai.Date >= Convert.ToDateTime(batdau).Date&& hientai.Date < Convert.ToDateTime(ketthuc).Date)
                    {
                        pt2[sotang] = phieuttcuakh[j];
                        sotang++;
                    }
                }
                phieuttcuakh = new Entities.PhieuTTCuaKH[sotang];
                if (sotang != 0)
                {
                    for (int j = 0; j < sotang; j++)
                    {
                        phieuttcuakh[j] = pt2[j];
                    }
                }
                else
                {
                    phieuttcuakh = new Entities.PhieuTTCuaKH[0];
                }
            }
            catch
            {
            }
            finally
            {
            }
        }
Ejemplo n.º 6
0
        private void SelectPhieuTTCuaKH()
        {
            try
            {
                if (phieuttcuakh == null || phieuttcuakh.Length == 0)
                {
                    phieuttcuakh = new Entities.PhieuTTCuaKH[0];
                    return;
                }

                Entities.PhieuTTCuaKH[] pt2 = new Entities.PhieuTTCuaKH[phieuttcuakh.Length];
                int sotang = 0;
                for (int j = 0; j < phieuttcuakh.Length; j++)
                {
                    DateTime hientai = phieuttcuakh[j].NgayLap;

                    if (phieuttcuakh[j].Deleted == false && hientai.Date >= Convert.ToDateTime(batdau).Date && hientai.Date < Convert.ToDateTime(ketthuc).Date)
                    {
                        pt2[sotang] = phieuttcuakh[j];
                        sotang++;
                    }
                }
                phieuttcuakh = new Entities.PhieuTTCuaKH[sotang];
                if (sotang != 0)
                {

                    for (int j = 0; j < sotang; j++)
                    {
                        phieuttcuakh[j] = pt2[j];
                    }
                }
                else
                    phieuttcuakh = new Entities.PhieuTTCuaKH[0];
            }
            catch
            {
            }
            finally
            {

            }
        }
Ejemplo n.º 7
0
        private void SelectPhieuTTCuaKH()
        {
            try
            {
                if (phieuttcuakh == null || phieuttcuakh.Length == 0)
                {
                    phieuttcuakh = new Entities.PhieuTTCuaKH[0];
                    return;
                }

                Entities.PhieuTTCuaKH[] pt2 = new Entities.PhieuTTCuaKH[phieuttcuakh.Length];
                int sotang = 0;
                for (int j = 0; j < phieuttcuakh.Length; j++)
                {
                    string month1 = phieuttcuakh[j].NgayLap.Month.ToString();
                    string year1 = phieuttcuakh[j].NgayLap.Year.ToString();

                    if (phieuttcuakh[j].Deleted == false && month1 == month && year1 == year)
                    {
                        pt2[sotang] = phieuttcuakh[j];
                        sotang++;
                    }
                }
                phieuttcuakh = new Entities.PhieuTTCuaKH[sotang];
                if (sotang != 0)
                {

                    for (int j = 0; j < sotang; j++)
                    {
                        phieuttcuakh[j] = pt2[j];
                    }
                }
                else
                    phieuttcuakh = new Entities.PhieuTTCuaKH[0];
            }
            catch { }
        }
Ejemplo n.º 8
0
        public void SelectPhieuTTCuaKH()
        {
            try
            {
                cl = new Server_Client.Client();
                // gán TCPclient
                this.client1 = cl.Connect(Luu.IP, Luu.Ports);
                // khởi tạo biến truyền vào với hàm khởi tạo
                Entities.PhieuTTCuaKH pttckh = new Entities.PhieuTTCuaKH();
                // truyền HanhDong
                pttckh = new Entities.PhieuTTCuaKH("Select");
                // khởi tạo mảng đối tượng để hứng giá trị
                Entities.PhieuTTCuaKH[] pttckh1 = new Entities.PhieuTTCuaKH[1];
                clientstrem = cl.SerializeObj(this.client1, "PhieuTTCuaKH", pttckh);
                // đổ mảng đối tượng vào datagripview
                pttckh1 = (Entities.PhieuTTCuaKH[])cl.DeserializeHepper1(clientstrem, pttckh1);
                if (pttckh1 == null)
                {
                    pttckh1 = new Entities.PhieuTTCuaKH[0];
                    pttkh = new Entities.PhieuTTCuaKH[0];
                    return;
                }

                Entities.PhieuTTCuaKH[] pttkhTEM = new Entities.PhieuTTCuaKH[pttckh1.Length];
                int sotang = 0;
                for (int j = 0; j < pttckh1.Length; j++)
                {
                    if (pttckh1[j].Deleted == false)
                    {
                        pttkhTEM[sotang] = pttckh1[j];
                        sotang++;
                    }
                }

                pttkh = new Entities.PhieuTTCuaKH[sotang];
                if (sotang != 0)
                {
                    for (int j = 0; j < sotang; j++)
                    {
                        pttkh[j] = pttkhTEM[j];
                    }
                }
                else
                    pttkh = new Entities.PhieuTTCuaKH[0];
            }
            catch (Exception ex)
            {
                pttkh = new Entities.PhieuTTCuaKH[0];
            }
        }
        /// <summary>
        /// select dữ liệu từ server
        /// </summary>
        public void SelectData()
        {
            try
            {
                dtgvThanhtoanKH.RowHeadersVisible = false;
                cl = new Server_Client.Client();
                // gán TCPclient
                this.client1 = cl.Connect(Luu.IP, Luu.Ports);
                // khởi tạo biến truyền vào với hàm khởi tạo
                Entities.PhieuTTCuaKH pttckh = new Entities.PhieuTTCuaKH();
                // truyền HanhDong
                pttckh = new Entities.PhieuTTCuaKH("Select");
                // khởi tạo mảng đối tượng để hứng giá trị
                pttckh1 = new Entities.PhieuTTCuaKH[1];
                clientstrem = cl.SerializeObj(this.client1, "PhieuTTCuaKH", pttckh);
                // đổ mảng đối tượng vào datagripview
                pttckh1 = (Entities.PhieuTTCuaKH[])cl.DeserializeHepper1(clientstrem, pttckh1);
                if (pttckh1 == null)
                {
                    tsslxoa.Enabled = false;
                    dtgvThanhtoanKH.DataSource = new Entities.PhieuTTCuaKH[0];
                    return;
                }
                tsslxoa.Enabled = true;

                Entities.PhieuTTCuaKH[] pttckh2 = new Entities.PhieuTTCuaKH[pttckh1.Length];
                int sotang = 0;
                for (int j = 0; j < pttckh1.Length; j++)
                {
                    if (pttckh1[j].Deleted == false)
                    {
                        pttckh2[sotang] = pttckh1[j];
                        sotang++;
                    }
                }

                hienthi = new Entities.PhieuTTCuaKH[sotang];
                if (sotang != 0)
                {
                    for (int j = 0; j < sotang; j++)
                    {
                        hienthi[j] = pttckh2[j];
                    }
                }
                else
                {
                    dtgvThanhtoanKH.DataSource = new Entities.PhieuTTCuaKH[0];
                    return;
                }
                dtgvThanhtoanKH.DataSource = hienthi;
                dtgvThanhtoanKH.Rows[0].Selected = true;
            }
            catch (Exception ex)
            {
                dtgvThanhtoanKH.DataSource = new Entities.PhieuTTCuaKH[0];
                tsslxoa.Enabled = false;
            }
            finally
            {
                fix();
            }
        }
 /// <summary>
 /// xử lý khi tìm kiếm
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void txttimkiem_TextChanged(object sender, EventArgs e)
 {
     try
     {
         if (rdbtimkiem3.Checked == true)
         {
             return;
         }
         if (txttimkiem.Text.Length == 0)
         {
             dtgvThanhtoanKH.DataSource = new Entities.PhieuTTCuaKH[0];
             return;
         }
         int soluong = 0;
         if (hienthi != null)
         {
             if (rdbtimkiem2.Checked == true)
             {
                 for (int i = 0; i < hienthi.Length; i++)
                 {
                     int kiemtra = hienthi[i].MaPhieuTTCuaKH.ToString().ToUpper().IndexOf(txttimkiem.Text.ToUpper());
                     if (kiemtra >= 0)
                     {
                         soluong++;
                     }
                 }
                 if (soluong == 0)
                 {
                     dtgvThanhtoanKH.DataSource = new Entities.PhieuTTCuaKH[0];
                     return;
                 }
                 Entities.PhieuTTCuaKH[] hienthitheoma = new Entities.PhieuTTCuaKH[soluong];
                 soluong = 0;
                 for (int i = 0; i < hienthi.Length; i++)
                 {
                     int kiemtra = hienthi[i].MaPhieuTTCuaKH.ToString().ToUpper().IndexOf(txttimkiem.Text.ToUpper());
                     if (kiemtra >= 0)
                     {
                         hienthitheoma[soluong] = hienthi[i];
                         soluong++;
                     }
                 }
                 dtgvThanhtoanKH.DataSource = hienthitheoma;
             }
         }
     }
     finally
     {
         fix();
     }
 }
        /// <summary>
        /// delete
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tsslxoa_Click(object sender, EventArgs e)
        {
            try
            {
                System.Windows.Forms.DialogResult giatri = System.Windows.Forms.MessageBox.Show("Bạn chắc chắn muốn Xóa không?", "Hệ Thống Cảnh Báo", System.Windows.Forms.MessageBoxButtons.YesNo);
                {
                    if (giatri == System.Windows.Forms.DialogResult.Yes)
                    {
                        bool ktdelete = false;
                        int idcurent = int.Parse(dtgvThanhtoanKH.Rows[i].Cells["PhieuTTCuaKHID"].Value.ToString());
                        SelectData();
                        for (int j = 0; j < pttckh1.Length; j++)
                        {
                            if (pttckh1[j].Deleted == false)
                                if (pttckh1[j].PhieuTTCuaKHID == idcurent)
                                {
                                    ktdelete = true;
                                    break;
                                }

                        }
                        if (ktdelete == true)
                        {
                            cl = new Server_Client.Client();
                            this.client1 = cl.Connect(Luu.IP, Luu.Ports);

                            Entities.PhieuTTCuaKH pt = new Entities.PhieuTTCuaKH();
                            pt = new Entities.PhieuTTCuaKH("Delete", idcurent);

                            clientstrem = cl.SerializeObj(this.client1, "PhieuTTCuaKH", pt);
                            bool kt = false;
                            kt = (bool)cl.DeserializeHepper(clientstrem, kt);
                            if (kt == true)
                            {
                                MessageBox.Show("Delete thanh cong");
                            }
                        }
                        else
                        {
                            MessageBox.Show("Hàng này đã bị xóa rồi");
                        }
                        SelectData();
                    }
                }
            }
            catch
            {
            }
        }
        /// <summary>
        /// select dữ liệu từ server
        /// </summary>
        public void SelectData()
        {
            try
            {
                dtgvThanhtoanKH.RowHeadersVisible = false;
                cl = new Server_Client.Client();
                // gán TCPclient
                this.client1 = cl.Connect(Luu.IP, Luu.Ports);
                // khởi tạo biến truyền vào với hàm khởi tạo
                Entities.PhieuTTCuaKH pttckh = new Entities.PhieuTTCuaKH();
                // truyền HanhDong
                pttckh = new Entities.PhieuTTCuaKH("Select");
                // khởi tạo mảng đối tượng để hứng giá trị
                pttckh1     = new Entities.PhieuTTCuaKH[1];
                clientstrem = cl.SerializeObj(this.client1, "PhieuTTCuaKH", pttckh);
                // đổ mảng đối tượng vào datagripview
                pttckh1 = (Entities.PhieuTTCuaKH[])cl.DeserializeHepper1(clientstrem, pttckh1);
                if (pttckh1 == null)
                {
                    tsslxoa.Enabled            = false;
                    dtgvThanhtoanKH.DataSource = new Entities.PhieuTTCuaKH[0];
                    return;
                }
                tsslxoa.Enabled = true;

                Entities.PhieuTTCuaKH[] pttckh2 = new Entities.PhieuTTCuaKH[pttckh1.Length];
                int sotang = 0;
                for (int j = 0; j < pttckh1.Length; j++)
                {
                    if (pttckh1[j].Deleted == false)
                    {
                        pttckh2[sotang] = pttckh1[j];
                        sotang++;
                    }
                }

                hienthi = new Entities.PhieuTTCuaKH[sotang];
                if (sotang != 0)
                {
                    for (int j = 0; j < sotang; j++)
                    {
                        hienthi[j] = pttckh2[j];
                    }
                }
                else
                {
                    dtgvThanhtoanKH.DataSource = new Entities.PhieuTTCuaKH[0];
                    return;
                }
                dtgvThanhtoanKH.DataSource       = hienthi;
                dtgvThanhtoanKH.Rows[0].Selected = true;
            }
            catch (Exception ex)
            {
                dtgvThanhtoanKH.DataSource = new Entities.PhieuTTCuaKH[0];
                tsslxoa.Enabled            = false;
            }
            finally
            {
                fix();
            }
        }
Ejemplo n.º 13
0
 public Entities.PhieuTTCuaKH[] PhieuTTCuaKH()
 {
     Entities.PhieuTTCuaKH[] pttckh1 = new BizLogic.PhieuTTCuaKH().Select();
     if (pttckh1 == null)
         pttckh1 = new Entities.PhieuTTCuaKH[0];
     return pttckh1;
 }