Ejemplo n.º 1
0
 public void CheckConflictUpdate()
 {
     try
     {
         cl = new Server_Client.Client();
         // gán TCPclient
         this.tcpClient = 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.Thue kh = new Entities.Thue("Select");
         // khởi tạo mảng đối tượng để hứng giá trị
         kh1           = new Entities.Thue[1];
         networkStream = cl.SerializeObj(this.tcpClient, "ThueH", kh);
         // đổ mảng đối tượng vào datagripview
         kh1 = (Entities.Thue[])cl.DeserializeHepper1(networkStream, kh1);
         if (kh1 != null)
         {
             for (int j = 0; j < kh1.Length; j++)
             {
                 if (kh1[j].MaThue == mathue)
                 {
                     kt = Check(kh1[j]);
                     break;
                 }
                 else
                 {
                     kt = "ok";
                 }
             }
         }
     }
     catch
     {
     }
 }
Ejemplo n.º 2
0
        public string Check(Entities.Thue kh)
        {
            try
            {
                string gt = "ok";

                if (giatrithue != kh.GiaTriThue)
                {
                    giatrithue = txtgiatrithue.Text = kh.GiaTriThue;
                    gt         = "ko";
                }
                if (tenthue != kh.TenThue)
                {
                    tenthue = txttenthue.Text = kh.TenThue;
                    gt      = "ko";
                }
                if (ghichu != kh.GhiChu)
                {
                    ghichu = txtghichu.Text = kh.GhiChu;
                    gt     = "ko";
                }
                return(gt);
            }
            catch
            {
                return("");
            }
        }
Ejemplo n.º 3
0
        private void tsslblxoa_Click(object sender, EventArgs e)
        {
            try
            {
                string maKH = dgvThue.Rows[i].Cells["MaThue"].Value.ToString();
                if (!frmDangNhap.User.Administrator && !CheckQuyen(this.Name, 3))
                {
                    MessageBox.Show("Bạn Không có quyền vào chức năng này.");
                    return;
                }
                if (new Check().CheckReference("Thue", maKH))
                {
                    DialogResult dlgResult = MessageBox.Show("Bạn Có Chắc Chắn muốn Xóa  không?", "Đồng ý?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (dlgResult == DialogResult.Yes)
                    {
                        bool ktdelete = false;
                        int  idcurent = int.Parse(dgvThue.Rows[i].Cells["ThueID"].Value.ToString());
                        SelectData();
                        for (int j = 0; j < kh1.Length; j++)
                        {
                            if (kh1[j].Deleted == false)
                            {
                                if (kh1[j].ThueID == idcurent)
                                {
                                    ktdelete = true;
                                    break;
                                }
                            }
                        }
                        if (ktdelete == true)
                        {
                            cl             = new Server_Client.Client();
                            this.tcpClient = cl.Connect(Luu.IP, Luu.Ports);

                            Entities.Thue kh = new Entities.Thue();
                            kh            = new Entities.Thue("Delete", idcurent, Common.Utilities.User.NhanVienID, Common.Utilities.User.TenDangNhap);
                            networkStream = cl.SerializeObj(this.tcpClient, "ThueH", kh);
                            bool kt = false;
                            kt = (bool)cl.DeserializeHepper(networkStream, kt);
                            if (kt == true)
                            {
                            }
                        }
                        else
                        {
                            MessageBox.Show("Thuế này đã bị xóa");
                        }
                        SelectData();
                    }
                }
                else
                {
                    MessageBox.Show("Thuế này không thể xóa! Hiện tại đang có giao dịch");
                }
            }
            catch { }
        }
Ejemplo n.º 4
0
 public Entities.Thue[] Thue()
 {
     Entities.Thue[] thue = new BizLogic.Thue().Select();
     if (thue == null)
     {
         thue = new Entities.Thue[0];
     }
     return(thue);
 }
Ejemplo n.º 5
0
 public void CheckConflictInsert()
 {
     try
     {
         cl = new Server_Client.Client();
         // gán TCPclient
         this.tcpClient = 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.Thue ncc = new Entities.Thue("Select");
         // khởi tạo mảng đối tượng để hứng giá trị
         Entities.Thue[] ncc1 = new Entities.Thue[1];
         networkStream = cl.SerializeObj(this.tcpClient, "ThueH", ncc);
         // đổ mảng đối tượng vào datagripview
         ncc1 = (Entities.Thue[])cl.DeserializeHepper1(networkStream, ncc1);
         if (ncc1 != null)
         {
             for (int j = 0; j < ncc1.Length; j++)
             {
                 if (ncc1[j].MaThue == mathue)
                 {
                     MessageBox.Show("cập nhật mã thuế- kiểm tra lại để insert");
                     kt     = "ko";
                     mathue = txtmathue.Text = ProID("Thue");
                     break;
                 }
                 else
                 {
                     kt = "ok";
                 }
             }
         }
         else
         {
             kt = "ok";
         }
     }
     catch
     {
     }
 }
Ejemplo n.º 6
0
        private void tsslblthem_Click(object sender, EventArgs e)
        {
            try
            {
                if (KiemTra())
                {
                    CheckConflictInsert();
                    if (kt == "ok")
                    {
                        if (txtghichu.Text == "")
                        {
                        }
                        ktgiatri = "a";
                        Server_Client.Client cl = new Server_Client.Client();
                        this.tcpClient = cl.Connect(Luu.IP, Luu.Ports);
                        Entities.Thue nv = new Entities.Thue();
                        nv            = new Entities.Thue("Insert", 0, txtmathue.Text, txtgiatrithue.Text, txttenthue.Text, txtghichu.Text, false, Common.Utilities.User.NhanVienID, Common.Utilities.User.TenDangNhap);
                        networkStream = cl.SerializeObj(this.tcpClient, "ThueH", nv);
                        int msg = 0;
                        msg = (int)cl.DeserializeHepper(networkStream, msg);
                        if (msg == 1)
                        {
                            this.Close();
                        }

                        else
                        {
                            MessageBox.Show("mã thuế đã thay đổi - kiểm tra lại dữ liệu");
                            txtmathue.Text = new Common.Utilities().ProcessID(txtmathue.Text);
                        }
                    }
                }
            }
            catch
            {
                MessageBox.Show("Xuất hiện lỗi");
            }
        }
Ejemplo n.º 7
0
 private void tsslblsua_Click(object sender, EventArgs e)
 {
     try
     {
         if (KiemTra() == true)
         {
             CheckConflictUpdate();
             if (kt == "ok")
             {
                 Server_Client.Client client = new Server_Client.Client();
                 this.tcpClient = client.Connect(Luu.IP, Luu.Ports);
                 Entities.Thue kh = new Entities.Thue();
                 kh            = new Entities.Thue("Update", int.Parse(id), txtmathue.Text, txtgiatrithue.Text, txttenthue.Text, txtghichu.Text, false, Common.Utilities.User.NhanVienID, Common.Utilities.User.TenDangNhap);
                 networkStream = client.SerializeObj(this.tcpClient, "ThueH", kh);
                 int msg = 0;
                 msg = (int)cl.DeserializeHepper(networkStream, msg);
                 if (msg == 1)
                 {
                 }
                 else
                 {
                     MessageBox.Show("Thất Bại");
                 }
                 this.Close();
             }
             else
             {
                 MessageBox.Show("Thay đổi dữ liệu");
             }
         }
     }
     catch
     {
         MessageBox.Show("Xuất hiện lỗi");
     }
 }
Ejemplo n.º 8
0
        //Lấy dữ liệu từ Database
        public void SelectData()
        {
            try
            {
                // i = 0;
                dgvThue.RowHeadersVisible = false;
                cl = new Server_Client.Client();
                // gán TCPclient
                this.tcpClient = 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.Thue kh = new Entities.Thue();
                // truyền HanhDong
                kh = new Entities.Thue("Select");
                // khởi tạo mảng đối tượng để hứng giá trị
                kh1           = new Entities.Thue[1];
                networkStream = cl.SerializeObj(this.tcpClient, "ThueH", kh);
                // đổ mảng đối tượng vào datagripview
                kh1 = (Entities.Thue[])cl.DeserializeHepper1(networkStream, kh1);
                //lbhienthitongso.Text = kh1.Length.ToString();
                if (kh1 == null)
                {
                    tsslblxoa.Enabled  = false;
                    hienthi            = new Entities.Thue[0];
                    dgvThue.DataSource = new Entities.Thue[0];
                    return;
                }
                tsslblxoa.Enabled = true;

                Entities.Thue[] pt2    = new Entities.Thue[kh1.Length];
                int             sotang = 0;
                for (int j = 0; j < kh1.Length; j++)
                {
                    if (kh1[j].Deleted == false)
                    {
                        pt2[sotang] = kh1[j];
                        sotang++;
                    }
                }
                hienthi = new Entities.Thue[sotang];
                if (sotang != 0)
                {
                    for (int j = 0; j < sotang; j++)
                    {
                        hienthi[j] = pt2[j];
                    }
                }
                else
                {
                    dgvThue.DataSource = new Entities.Thue[0];
                    return;
                }
                dgvThue.DataSource = hienthi;
                new Common.Utilities().CountDatagridview(dgvThue);

                dgvThue.Rows[0].Selected = true;
            }
            finally
            {
                try
                {
                    for (int j = 1; j < dgvThue.ColumnCount; j++)
                    {
                        dgvThue.Columns[j].Visible = false;
                    }
                    dgvThue.Columns[0].Visible               = true;
                    dgvThue.Columns[0].HeaderText            = "STT";
                    dgvThue.Columns["MaThue"].HeaderText     = "Mã Thuế";
                    dgvThue.Columns["GiaTriThue"].HeaderText = "Giá Trị Thuế";
                    dgvThue.Columns["TenThue"].HeaderText    = "Tên Thuế";
                    dgvThue.Columns["GhiChu"].HeaderText     = "Ghi Chú";
                    dgvThue.Columns["MaThue"].Visible        = true;
                    dgvThue.Columns["GiaTriThue"].Visible    = true;
                    dgvThue.Columns["TenThue"].Visible       = true;
                    dgvThue.Columns["GhiChu"].Visible        = true;
                    dgvThue.AutoSizeColumnsMode              = DataGridViewAutoSizeColumnsMode.Fill;
                    dgvThue.AllowUserToAddRows               = false;
                    dgvThue.AllowUserToDeleteRows            = false;
                    dgvThue.AllowUserToResizeRows            = false;
                }
                catch {
                    MessageBox.Show("Xuất hiện lỗi");
                }
            }
        }
Ejemplo n.º 9
0
 private void txttimkiem_TextChanged(object sender, EventArgs e)
 {
     try
     {
         if (rdbtatca.Checked == true)
         {
             return;
         }
         if (txttimkiem.Text.Length == 0)
         {
             dgvThue.DataSource = new Entities.Thue[0];
             return;
         }
         int soluong = 0;
         if (hienthi != null)
         {
             if (rdbtheoma.Checked == true)
             {
                 for (int i = 0; i < hienthi.Length; i++)
                 {
                     int kiemtra = hienthi[i].TenThue.ToString().ToUpper().IndexOf(txttimkiem.Text.ToUpper());
                     if (kiemtra >= 0)
                     {
                         soluong++;
                     }
                 }
                 if (soluong == 0)
                 {
                     dgvThue.DataSource = new Entities.Thue[0];
                     return;
                 }
                 Entities.Thue[] hienthitheoid = new Entities.Thue[soluong];
                 soluong = 0;
                 for (int i = 0; i < hienthi.Length; i++)
                 {
                     int kiemtra = hienthi[i].TenThue.ToString().ToUpper().IndexOf(txttimkiem.Text.ToUpper());
                     if (kiemtra >= 0)
                     {
                         hienthitheoid[soluong] = hienthi[i];
                         soluong++;
                     }
                 }
                 dgvThue.DataSource = hienthitheoid;
             }
             if (rdbtheoten.Checked == true)
             {
                 for (int i = 0; i < hienthi.Length; i++)
                 {
                     int kiemtra = hienthi[i].MaThue.ToString().ToUpper().IndexOf(txttimkiem.Text.ToUpper());
                     if (kiemtra >= 0)
                     {
                         soluong++;
                     }
                 }
                 if (soluong == 0)
                 {
                     dgvThue.DataSource = new Entities.Thue[0];
                     return;
                 }
                 Entities.Thue[] hienthitheoma = new Entities.Thue[soluong];
                 soluong = 0;
                 for (int i = 0; i < hienthi.Length; i++)
                 {
                     int kiemtra = hienthi[i].MaThue.ToString().ToUpper().IndexOf(txttimkiem.Text.ToUpper());
                     if (kiemtra >= 0)
                     {
                         hienthitheoma[soluong] = hienthi[i];
                         soluong++;
                     }
                 }
                 dgvThue.DataSource = hienthitheoma;
             }
         }
     }
     finally
     {
         try
         {
             for (int j = 1; j < dgvThue.ColumnCount; j++)
             {
                 dgvThue.Columns[j].Visible = false;
             }
             new Common.Utilities().CountDatagridview(dgvThue);
             dgvThue.Columns[0].Visible               = true;
             dgvThue.Columns[0].HeaderText            = "STT";
             dgvThue.Columns["MaThue"].HeaderText     = "Mã Thuế";
             dgvThue.Columns["GiaTriThue"].HeaderText = "Giá Trị Thuế";
             dgvThue.Columns["TenThue"].HeaderText    = "Tên Thuế";
             dgvThue.Columns["GhiChu"].HeaderText     = "Ghi Chú";
             dgvThue.Columns["MaThue"].Visible        = true;
             dgvThue.Columns["GiaTriThue"].Visible    = true;
             dgvThue.Columns["TenThue"].Visible       = true;
             dgvThue.Columns["GhiChu"].Visible        = true;
             dgvThue.AutoSizeColumnsMode              = DataGridViewAutoSizeColumnsMode.Fill;
             dgvThue.AllowUserToAddRows               = false;
             dgvThue.AllowUserToDeleteRows            = false;
             dgvThue.AllowUserToResizeRows            = false;
             dgvThue.RowHeadersVisible = false;
         }
         catch {
             MessageBox.Show("Xuất hiện lỗi");
         }
     }
 }
Ejemplo n.º 10
0
        /// <summary>
        /// lấy giá trị thuế
        /// </summary>
        /// <param name="maThue"></param>
        private void LayGiaTriThue(string maThue)
        {
            try
            {
                cl = new Server_Client.Client();
                this.client1 = cl.Connect(Luu.IP, Luu.Ports);

                Entities.Thue kh = new Entities.Thue();
                kh = new Entities.Thue("Select");
                clientstrem = cl.SerializeObj(this.client1, "Thue", kh);
                Entities.Thue[] thue = new Entities.Thue[1];
                thue = (Entities.Thue[])cl.DeserializeHepper1(clientstrem, thue);

                if (thue.Length > 0)
                {
                    int sl = thue.Length;
                    for (int i = 0; i < sl; i++)
                    {
                        if (thue[i].Deleted == false && thue[i].MaThue == maThue)
                        {
                            thuegtgt = toolStrip_txtThuegiatrigiatang.Text = thue[i].GiaTriThue;
                            return;
                        }
                    }
                }
                toolStrip_txtThuegiatrigiatang.Text = "0";
            }
            catch
            {
                return;
            }
            finally
            {

            }
        }
Ejemplo n.º 11
0
        public void CheckConflictInsert()
        {
            try
             {
                 cl = new Server_Client.Client();
                 // gán TCPclient
                 this.tcpClient = 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.Thue ncc = new Entities.Thue("Select");
                 // khởi tạo mảng đối tượng để hứng giá trị
                 Entities.Thue[] ncc1 = new Entities.Thue[1];
                 networkStream = cl.SerializeObj(this.tcpClient, "ThueH", ncc);
                 // đổ mảng đối tượng vào datagripview
                 ncc1 = (Entities.Thue[])cl.DeserializeHepper1(networkStream, ncc1);
                 if (ncc1 != null)
                 {
                     for (int j = 0; j < ncc1.Length; j++)
                     {
                         if (ncc1[j].MaThue == mathue)
                         {
                             MessageBox.Show("cập nhật mã thuế- kiểm tra lại để insert");
                             kt = "ko";
                             mathue = txtmathue.Text = ProID("Thue");
                             break;
                         }
                         else
                             kt = "ok";
                     }

                 }
                 else
                     kt = "ok";

             }
             catch
             {
             }
        }
Ejemplo n.º 12
0
        private void tsslblthem_Click(object sender, EventArgs e)
        {
            try
             {
             if (KiemTra())
             {
                 CheckConflictInsert();
                 if (kt == "ok")
                 {
                     if (txtghichu.Text == "")
                     { }
                     ktgiatri = "a";
                     Server_Client.Client cl = new Server_Client.Client();
                     this.tcpClient = cl.Connect(Luu.IP, Luu.Ports);
                     Entities.Thue nv = new Entities.Thue();
                     nv = new Entities.Thue("Insert", 0, txtmathue.Text, txtgiatrithue.Text, txttenthue.Text, txtghichu.Text, false, Common.Utilities.User.NhanVienID, Common.Utilities.User.TenDangNhap);
                     networkStream = cl.SerializeObj(this.tcpClient, "ThueH", nv);
                     int msg = 0;
                     msg = (int)cl.DeserializeHepper(networkStream, msg);
                     if (msg == 1)
                     {
                         this.Close();
                     }

                     else
                     {
                         MessageBox.Show("mã thuế đã thay đổi - kiểm tra lại dữ liệu");
                         txtmathue.Text = new Common.Utilities().ProcessID(txtmathue.Text);
                     }

                 }

             }
             }
             catch
             {
                 MessageBox.Show("Xuất hiện lỗi");
             }
        }
Ejemplo n.º 13
0
 private void tsslblsua_Click(object sender, EventArgs e)
 {
     try
      {
      if (KiemTra() == true)
      {
          CheckConflictUpdate();
          if (kt == "ok")
          {
              Server_Client.Client client = new Server_Client.Client();
              this.tcpClient = client.Connect(Luu.IP, Luu.Ports);
              Entities.Thue kh = new Entities.Thue();
              kh = new Entities.Thue("Update", int.Parse(id), txtmathue.Text, txtgiatrithue.Text, txttenthue.Text, txtghichu.Text, false, Common.Utilities.User.NhanVienID, Common.Utilities.User.TenDangNhap);
              networkStream = client.SerializeObj(this.tcpClient, "ThueH", kh);
              int msg = 0;
              msg = (int)cl.DeserializeHepper(networkStream, msg);
              if (msg == 1)
              {
              }
              else
                  MessageBox.Show("Thất Bại");
              this.Close();
          }
          else
          {
              MessageBox.Show("Thay đổi dữ liệu");
          }
      }
      }
      catch
      {
          MessageBox.Show("Xuất hiện lỗi");
      }
 }
Ejemplo n.º 14
0
        public void CheckConflictUpdate()
        {
            try
             {
                 cl = new Server_Client.Client();
                 // gán TCPclient
                 this.tcpClient = 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.Thue kh = new Entities.Thue("Select");
                 // khởi tạo mảng đối tượng để hứng giá trị
                 kh1 = new Entities.Thue[1];
                 networkStream = cl.SerializeObj(this.tcpClient, "ThueH", kh);
                 // đổ mảng đối tượng vào datagripview
                 kh1 = (Entities.Thue[])cl.DeserializeHepper1(networkStream, kh1);
                 if (kh1 != null)
                 {
                     for (int j = 0; j < kh1.Length; j++)
                     {
                         if (kh1[j].MaThue == mathue)
                         {

                             kt = Check(kh1[j]);
                             break;
                         }
                         else
                             kt = "ok";
                     }

                 }

             }
             catch
             {
             }
        }
Ejemplo n.º 15
0
 public Entities.Thue[] Thue()
 {
     Entities.Thue[] thue = new BizLogic.Thue().Select();
     if (thue == null)
         thue = new Entities.Thue[0];
     return thue;
 }