Ejemplo n.º 1
0
        public int InsertUpdate(Entities.TienTe tt1)
        {
            try
            {
                tt  = new Constants.TienTe();
                Sql = new Constants.Sql();
                string        sql  = Sql.InsertUpdateTienTe;
                Connection    conn = new Connection();
                SqlConnection cn   = conn.openConnection();
                SqlCommand    cmd  = new SqlCommand(sql, cn);
                cmd.Parameters.Add(tt.HanhDong, SqlDbType.NVarChar, 20).Value       = tt1.HanhDong;
                cmd.Parameters.Add(tt.TienteID, SqlDbType.Int).Value                = tt1.TienteID;
                cmd.Parameters.Add(tt.MaTienTe, SqlDbType.NVarChar, 20).Value       = tt1.MaTienTe;
                cmd.Parameters.Add(tt.TenTienTe, SqlDbType.NVarChar, 200).Value     = tt1.TenTienTe;
                cmd.Parameters.Add(tt.TenTienTeChan, SqlDbType.NVarChar, 200).Value = tt1.TenTienTeChan;
                cmd.Parameters.Add(tt.TenTienTeLe, SqlDbType.NVarChar, 200).Value   = tt1.TenTienTeLe;
                cmd.Parameters.Add(tt.BieuTuong, SqlDbType.NVarChar, 20).Value      = tt1.BieuTuong;
                cmd.Parameters.Add(tt.DonViLamTron, SqlDbType.Int).Value            = tt1.DonViLamTron;
                cmd.Parameters.Add(tt.GhiChu, SqlDbType.NVarChar, 100).Value        = tt1.GhiChu;
                cmd.Parameters.Add(tt.Deleted, SqlDbType.Bit).Value = tt1.Deleted;

                int i = cmd.ExecuteNonQuery();
                cmd.Connection.Dispose();
                cn.Close();
                conn.closeConnection();
                cn   = null;
                conn = null;
                return(i);
            }
            catch (Exception ex)
            {
                string s = ex.Message;
                return(0);
            }
        }
Ejemplo n.º 2
0
        public void Delete(Entities.TienTe tt1)
        {
            try
            {
                tt = new Constants.TienTe();
                Entities.TienTe tiente = new Entities.TienTe();
                Sql = new Constants.Sql();
                string        sql  = Sql.DeleteTienTe;
                Connection    conn = new Connection();
                SqlConnection cn   = conn.openConnection();
                SqlCommand    cmd  = new SqlCommand(sql, cn);
                cmd.Parameters.Add(tt.HanhDong, SqlDbType.NVarChar, 20).Value = tt1.HanhDong;
                cmd.Parameters.Add(tt.TienteID, SqlDbType.Int).Value          = tt1.TienteID;

                cmd.ExecuteNonQuery();
                cmd.Connection.Dispose();
                cn.Close();
                conn.closeConnection();
                cn   = null;
                conn = null;
            }
            catch (Exception ex)
            {
                string s = ex.Message;
            }
        }
Ejemplo n.º 3
0
 public void CheckConflictUpdate()
 {
     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.TienTe tt = new Entities.TienTe("Select", 1);
         // khởi tạo mảng đối tượng để hứng giá trị
         tt1          = new Entities.TienTe[1];
         clientstream = cl.SerializeObj(this.client1, "TienTe", tt);
         // đổ mảng đối tượng vào datagripview
         tt1 = (Entities.TienTe[])cl.DeserializeHepper1(clientstream, tt1);
         if (tt1 != null)
         {
             for (int j = 0; j < tt1.Length; j++)
             {
                 if (tt1[j].MaTienTe == maTienTe)
                 {
                     kt = Check(tt1[j]);
                     break;
                 }
                 else
                 {
                     kt = "null";
                 }
             }
         }
     }
     catch
     {
     }
 }
Ejemplo n.º 4
0
        public void Delete(Entities.TienTe tt1)
        {
            try
            {
                tt = new Constants.TienTe();
                Entities.TienTe tiente = new Entities.TienTe();
                Sql = new Constants.Sql();
                string sql = Sql.DeleteTienTe;
                Connection conn = new Connection();
                SqlConnection cn = conn.openConnection();
                SqlCommand cmd = new SqlCommand(sql, cn);
                cmd.Parameters.Add(tt.HanhDong, SqlDbType.NVarChar, 20).Value = tt1.HanhDong;
                cmd.Parameters.Add(tt.TienteID, SqlDbType.Int).Value = tt1.TienteID;

                cmd.ExecuteNonQuery();
                cmd.Connection.Dispose();
                cn.Close();
                conn.closeConnection();
                cn = null;
                conn = null;
            }
            catch (Exception ex)
            {
                string s = ex.Message;
            }
        }
Ejemplo n.º 5
0
 private void tsslThem_Click(object sender, EventArgs e)
 {
     if (Validate())
     {
         CheckConflictInsert();
         if (kt == "ok")
         {
             cl           = new Server_Client.Client();
             this.client1 = cl.Connect(Luu.IP, Luu.Ports);
             Entities.TienTe tt = new Entities.TienTe("Insert", 1, txtmatt.Text, txttentt.Text, txttenttc.Text, txttenttl.Text, txtbieutuong.Text, Convert.ToInt32(txtdonvi.Text), txtghichu.Text, false, Common.Utilities.User.NhanVienID, Common.Utilities.User.TenDangNhap);
             clientstream = cl.SerializeObj(this.client1, "TienTe", tt);
             int msg = 0;
             msg = (int)cl.DeserializeHepper(clientstream, msg);
             if (msg == 1)
             {
                 txtmatt.Text            = LayID("TienTe");
                 txttentt.Text           = "";
                 txttenttc.Text          = "";
                 txttenttl.Text          = "";
                 txtbieutuong.Text       = "";
                 txtdonvi.Text           = "";
                 txtghichu.Text          = "";
                 frmQuanlytiente.KiemTra = "insert";
                 this.Close();
             }
             else
             {
                 MessageBox.Show("Insert that bai");
             }
         }
     }
 }
Ejemplo n.º 6
0
        public void hienthi()
        {
            Server_Client.Client cl = new Server_Client.Client();
            this.client1 = cl.Connect(Luu.IP, Luu.Ports);
            tt           = new TienTe("Select", 1, "a", "a", "a", "a", "a", 1000, "a", false, Common.Utilities.User.NhanVienID, Common.Utilities.User.TenDangNhap);
            clientstrem  = cl.SerializeObj(this.client1, "TienTe", tt);

            TienTe[] tt1 = new TienTe[1];
            tt1[0] = new TienTe(1, "a", "a", "a", "a", "a", 1000, "a", false);
            tt1    = (TienTe[])cl.DeserializeHepper1(clientstrem, tt1);


            if (tt1 == null)
            {
                Entities.TienTe [] a = new Entities.TienTe[0];
                TT_Search = a;
                dataGridView1.DataSource = a;
                FixDataGridView();
                toolStripStatus_Sua.Enabled = false;
                toolStripStatus_Xoa.Enabled = false;
            }
            else
            {
                TT_Search = tt1;
                dataGridView1.DataSource = tt1;
                FixDataGridView();
                toolStripStatus_Sua.Enabled = true;
                toolStripStatus_Xoa.Enabled = true;
            }
        }
Ejemplo n.º 7
0
        public Entities.TienTe[] Select()
        {
            Entities.TienTe[] arrC = null;
            try
            {
                tt  = new Constants.TienTe();
                Sql = new Constants.Sql();
                string sql = Sql.SelectAllTienTe;
                conn = new Connection();
                cn   = conn.openConnection();
                cmd  = new SqlCommand(sql, cn);
                dr   = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                arr  = new ArrayList();
                while (dr.Read())
                {
                    Entities.TienTe tiente = new Entities.TienTe();
                    tiente.TienteID      = Convert.ToInt32(dr[tt.TienteID].ToString());
                    tiente.MaTienTe      = dr[tt.MaTienTe].ToString();
                    tiente.TenTienTe     = dr[tt.TenTienTe].ToString();
                    tiente.TenTienTeChan = dr[tt.TenTienTeChan].ToString();
                    tiente.TenTienTeLe   = dr[tt.TenTienTeLe].ToString();
                    tiente.TenTienTe     = dr[tt.TenTienTe].ToString();
                    tiente.BieuTuong     = dr[tt.BieuTuong].ToString();
                    tiente.DonViLamTron  = (int)dr[tt.DonViLamTron];
                    tiente.GhiChu        = dr[tt.GhiChu].ToString();
                    tiente.Deleted       = (Boolean)dr[tt.Deleted];
                    arr.Add(tiente);
                }
                int n = arr.Count;
                if (n == 0)
                {
                    return(null);
                }
                arrC = new Entities.TienTe[n];
                for (int i = 0; i < n; i++)
                {
                    arrC[i] = (Entities.TienTe)arr[i];
                }
            }

            catch (Exception ex)
            { string s = ex.Message.ToString(); }
            finally
            {
                cmd.Connection.Dispose();
                cn.Close();
                conn.closeConnection();
            }

            return(arrC);
        }
Ejemplo n.º 8
0
        public string Check(Entities.TienTe tt)
        {
            string gt = "ok";

            if (tenTienTe != tt.TenTienTe)
            {
                tenTienTe = txttentt.Text = tt.TenTienTe;
                gt        = "ko";
            }
            if (tenTienTeLe != tt.TenTienTeLe)
            {
                tenTienTeLe = txttenttl.Text = tt.TenTienTeLe;
                gt          = "ko";
            }

            if (tenTienTeChan != tt.TenTienTeChan)
            {
                tenTienTeChan = txttenttc.Text = tt.TenTienTeChan;
                gt            = "ko";
            }
            if (bieuTuong != tt.BieuTuong)
            {
                bieuTuong = txtbieutuong.Text = tt.BieuTuong.ToString();
                gt        = "ko";
            }
            if (donViLamTron != tt.DonViLamTron)
            {
                donViLamTron  = tt.DonViLamTron;
                txtdonvi.Text = donViLamTron.ToString();
                gt            = "ko";
            }

            if (ghiChu != tt.GhiChu)
            {
                ghiChu = txtghichu.Text = tt.GhiChu;
                gt     = "ko";
            }

            if (gt == "ko")
            {
                MessageBox.Show("Dữ liệu đã có thay đổi trước, ấn ok để cập nhật lại.");
            }

            return(gt);
        }
Ejemplo n.º 9
0
 public void CheckConflictInsert()
 {
     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.TienTe tt = new Entities.TienTe("Select", 1);
         // khởi tạo mảng đối tượng để hứng giá trị
         Entities.TienTe[] tknh1 = new Entities.TienTe[1];
         clientstream = cl.SerializeObj(this.client1, "TienTe", tt);
         // đổ mảng đối tượng vào datagripview
         tknh1 = (Entities.TienTe[])cl.DeserializeHepper1(clientstream, tknh1);
         if (tknh1 != null)
         {
             for (int j = 0; j < tknh1.Length; j++)
             {
                 if (tknh1[j].MaTienTe == txtmatt.Text)
                 {
                     MessageBox.Show("cập nhật mã Tài Khoản Ngân Hàng - kiểm tra lại để insert");
                     kt           = "ko";
                     txtmatt.Text = LayID("TienTe");
                     break;
                 }
                 else
                 {
                     kt = "ok";
                 }
             }
         }
         else
         {
             kt = "ok";
         }
     }
     catch
     {
     }
 }
Ejemplo n.º 10
0
 private void tsslSua_Click(object sender, EventArgs e)
 {
     if (Validate())
     {
         CheckConflictUpdate();
         if (kt == "ok")
         {
             Server_Client.Client cl = new Server_Client.Client();
             this.client1 = cl.Connect(Luu.IP, Luu.Ports);
             Entities.TienTe tt = new Entities.TienTe("Update", Convert.ToInt32(txtID.Text), txtmatt.Text, txttentt.Text, txttenttc.Text, txttenttl.Text, txtbieutuong.Text, Convert.ToInt32(txtdonvi.Text), txtghichu.Text, false, Common.Utilities.User.NhanVienID, Common.Utilities.User.TenDangNhap);
             clientstream = cl.SerializeObj(this.client1, "TienTe", tt);
             int msg = 0;
             msg = (int)cl.DeserializeHepper(clientstream, msg);
             if (msg == 1)
             {
                 tenTienTe     = txttentt.Text;
                 tenTienTeChan = txttenttc.Text;
                 tenTienTeLe   = txttenttl.Text;
                 bieuTuong     = txtbieutuong.Text;
                 donViLamTron  = int.Parse(txtdonvi.Text);
                 ghiChu        = txtghichu.Text;
                 this.Close();
             }
             else
             {
                 MessageBox.Show("Update that bai");
             }
         }
         else
         if (kt == "null")
         {
             MessageBox.Show("Bản ghi đã bị xóa bởi người dùng khác. Mời bạn xử lý bản ghi khác");
             this.Close();
         }
     }
 }
Ejemplo n.º 11
0
        public Entities.TienTe[] Select()
        {
            Entities.TienTe[] arrC = null;
            try
            {
                tt = new Constants.TienTe();
                Sql = new Constants.Sql();
                string sql = Sql.SelectAllTienTe;
                conn = new Connection();
                cn = conn.openConnection();
                cmd = new SqlCommand(sql, cn);
                dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                arr = new ArrayList();
                while (dr.Read())
                {
                    Entities.TienTe tiente = new Entities.TienTe();
                    tiente.TienteID = Convert.ToInt32(dr[tt.TienteID].ToString());
                    tiente.MaTienTe = dr[tt.MaTienTe].ToString();
                    tiente.TenTienTe = dr[tt.TenTienTe].ToString();
                    tiente.TenTienTeChan = dr[tt.TenTienTeChan].ToString();
                    tiente.TenTienTeLe = dr[tt.TenTienTeLe].ToString();
                    tiente.TenTienTe = dr[tt.TenTienTe].ToString();
                    tiente.BieuTuong = dr[tt.BieuTuong].ToString();
                    tiente.DonViLamTron = (int)dr[tt.DonViLamTron];
                    tiente.GhiChu = dr[tt.GhiChu].ToString();
                    tiente.Deleted = (Boolean)dr[tt.Deleted];
                    arr.Add(tiente);
                }
                int n = arr.Count;
                if (n == 0) { return null; }
                arrC = new Entities.TienTe[n];
                for (int i = 0; i < n; i++)
                {
                    arrC[i] = (Entities.TienTe)arr[i];
                }
            }

            catch (Exception ex)
            { string s = ex.Message.ToString(); }
            finally
            {
                cmd.Connection.Dispose();
                cn.Close();
                conn.closeConnection();
            }

            return arrC;
        }
Ejemplo n.º 12
0
        /// <summary>
        /// lấy tên tiền tệ
        /// </summary>
        public void LayTenTT()
        {
            try
            {
                cbbtientetygia.Items.Clear();
                cl = new Server_Client.Client();
                this.client1 = cl.Connect(Luu.IP, Luu.Ports);

                Entities.TienTe tt1 = new Entities.TienTe();
                tt1 = new Entities.TienTe("Select");
                clientstrem = cl.SerializeObj(this.client1, "TienTe", tt1);
                tt = new Entities.TienTe[1];
                tt = (Entities.TienTe[])cl.DeserializeHepper1(clientstrem, tt);
                if (tt == null)
                    tt = new Entities.TienTe[0];
                if (tt.Length > 0)
                {
                    int sl = tt.Length;
                    for (int i = 0; i < sl; i++)
                    {
                        cbbtientetygia.Items.Add(tt[i].TenTienTe);
                    }
                    cbbtientetygia.SelectedIndex = 0;
                }
            }
            catch
            {
                cbbtientetygia.Items.Clear();
                cbbtientetygia.Text = "";
            }
            finally
            {

            }
        }
Ejemplo n.º 13
0
        private void tsslThem_Click(object sender, EventArgs e)
        {
            if (Validate())
            {
                CheckConflictInsert();
                if (kt == "ok")
                {
                    cl = new Server_Client.Client();
                    this.client1 = cl.Connect(Luu.IP, Luu.Ports);
                    Entities.TienTe tt = new Entities.TienTe("Insert", 1, txtmatt.Text, txttentt.Text, txttenttc.Text, txttenttl.Text, txtbieutuong.Text, Convert.ToInt32(txtdonvi.Text), txtghichu.Text, false, Common.Utilities.User.NhanVienID, Common.Utilities.User.TenDangNhap);
                    clientstream = cl.SerializeObj(this.client1, "TienTe", tt);
                    int msg = 0;
                    msg = (int)cl.DeserializeHepper(clientstream, msg);
                    if (msg == 1)
                    {
                        txtmatt.Text = LayID("TienTe");
                        txttentt.Text = "";
                        txttenttc.Text = "";
                        txttenttl.Text = "";
                        txtbieutuong.Text = "";
                        txtdonvi.Text = "";
                        txtghichu.Text = "";
                        frmQuanlytiente.KiemTra = "insert";
                        this.Close();
                    }
                    else
                        MessageBox.Show("Insert that bai");

                }
            }
        }
Ejemplo n.º 14
0
        private void tsslSua_Click(object sender, EventArgs e)
        {
            if (Validate())
            {
                CheckConflictUpdate();
                if (kt == "ok")
                {
                    Server_Client.Client cl = new Server_Client.Client();
                    this.client1 = cl.Connect(Luu.IP, Luu.Ports);
                    Entities.TienTe tt = new Entities.TienTe("Update", Convert.ToInt32(txtID.Text), txtmatt.Text, txttentt.Text, txttenttc.Text, txttenttl.Text, txtbieutuong.Text, Convert.ToInt32(txtdonvi.Text), txtghichu.Text, false, Common.Utilities.User.NhanVienID, Common.Utilities.User.TenDangNhap);
                    clientstream = cl.SerializeObj(this.client1, "TienTe", tt);
                    int msg = 0;
                    msg = (int)cl.DeserializeHepper(clientstream, msg);
                    if (msg == 1)
                    {
                        tenTienTe = txttentt.Text;
                        tenTienTeChan = txttenttc.Text;
                        tenTienTeLe = txttenttl.Text;
                        bieuTuong = txtbieutuong.Text;
                        donViLamTron = int.Parse(txtdonvi.Text);
                        ghiChu = txtghichu.Text;
                        this.Close();
                    }
                    else
                        MessageBox.Show("Update that bai");

                }
                else
                    if (kt == "null")
                    {
                        MessageBox.Show("Bản ghi đã bị xóa bởi người dùng khác. Mời bạn xử lý bản ghi khác");
                        this.Close();
                    }
            }
        }
Ejemplo n.º 15
0
        public void CheckConflictUpdate()
        {
            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.TienTe tt = new Entities.TienTe("Select", 1);
                // khởi tạo mảng đối tượng để hứng giá trị
                tt1 = new Entities.TienTe[1];
                clientstream = cl.SerializeObj(this.client1, "TienTe", tt);
                // đổ mảng đối tượng vào datagripview
                tt1 = (Entities.TienTe[])cl.DeserializeHepper1(clientstream, tt1);
                if (tt1 != null)
                {
                    for (int j = 0; j < tt1.Length; j++)
                    {
                        if (tt1[j].MaTienTe == maTienTe)
                        {
                            kt = Check(tt1[j]);
                            break;
                        }
                        else
                            kt = "null";
                    }
                }

            }
            catch
            {
            }
        }
Ejemplo n.º 16
0
        public void CheckConflictInsert()
        {
            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.TienTe tt = new Entities.TienTe("Select", 1);
                // khởi tạo mảng đối tượng để hứng giá trị
                Entities.TienTe[] tknh1 = new Entities.TienTe[1];
                clientstream = cl.SerializeObj(this.client1, "TienTe", tt);
                // đổ mảng đối tượng vào datagripview
                tknh1 = (Entities.TienTe[])cl.DeserializeHepper1(clientstream, tknh1);
                if (tknh1 != null)
                {
                    for (int j = 0; j < tknh1.Length; j++)
                    {
                        if (tknh1[j].MaTienTe == txtmatt.Text)
                        {
                            MessageBox.Show("cập nhật mã Tài Khoản Ngân Hàng - kiểm tra lại để insert");
                            kt = "ko";
                            txtmatt.Text = LayID("TienTe");
                            break;
                        }
                        else
                            kt = "ok";
                    }

                }
                else
                    kt = "ok";

            }
            catch
            {
            }
        }