Example #1
0
        //insert update
        public int InsertUpdate(Entities.Thue dvt1)
        {
            try
            {
                dvt = new Constants.ThueH();
                Sql = new Constants.Sql();
                string        sql  = Sql.InsertUpdateThue;
                Connection    conn = new Connection();
                SqlConnection cn   = conn.openConnection();
                SqlCommand    cmd  = new SqlCommand(sql, cn);
                cmd.Parameters.Add(dvt.HanhDong, SqlDbType.NVarChar, 20).Value = dvt1.HanhDong;
                cmd.Parameters.Add(dvt.ThueID, SqlDbType.Int).Value            = dvt1.ThueID;
                cmd.Parameters.Add(dvt.MaThue, SqlDbType.VarChar, 20).Value    = dvt1.MaThue;
                cmd.Parameters.Add(dvt.GiaTriThue, SqlDbType.Float).Value      = dvt1.GiaTriThue;
                cmd.Parameters.Add(dvt.TenThue, SqlDbType.NVarChar, 100).Value = dvt1.TenThue;
                cmd.Parameters.Add(dvt.GhiChu, SqlDbType.NVarChar, 100).Value  = dvt1.GhiChu;
                cmd.Parameters.Add(dvt.Deleted, SqlDbType.Bit).Value           = dvt1.Deleted;

                int i = cmd.ExecuteNonQuery();
                cmd.Connection.Dispose();
                cn.Close();
                conn.closeConnection();
                cn   = null;
                conn = null;
                return(i);
            }
            catch (Exception ex)
            {
                return(0);
            }
        }
Example #2
0
 public ThueH()
 {
     dvt       = null;
     Sql       = null;
     conn      = null;
     cmd       = null;
     arr       = null;
     dr        = null;
     donvitinh = null;
     cn        = null;
 }
Example #3
0
 public ThueH()
 {
     dvt = null;
     Sql = null;
     conn = null;
     cmd = null;
     arr = null;
     dr = null;
     donvitinh = null;
     cn = null;
 }
Example #4
0
        public Entities.Thue[] sp_SelectThuesAll()
        {
            Entities.Thue[] arrC = null;
            try
            {
                dvt = new Constants.ThueH();
                Sql = new Constants.Sql();
                string sql = Sql.SelectThue;
                conn = new Connection();
                cn   = conn.openConnection();
                cmd  = new SqlCommand(sql, cn);
                dr   = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                arr  = new ArrayList();
                while (dr.Read())
                {
                    donvitinh            = new Entities.Thue();
                    donvitinh.ThueID     = Convert.ToInt32(dr[dvt.ThueID].ToString());
                    donvitinh.MaThue     = dr[dvt.MaThue].ToString();
                    donvitinh.GiaTriThue = dr[dvt.GiaTriThue].ToString();
                    donvitinh.TenThue    = dr[dvt.TenThue].ToString();
                    donvitinh.GhiChu     = dr[dvt.GhiChu].ToString();
                    donvitinh.Deleted    = (Boolean)dr[dvt.Deleted];
                    arr.Add(donvitinh);
                }
                int n = arr.Count;
                if (n == 0)
                {
                    return(null);
                }
                arrC = new Entities.Thue[n];
                for (int i = 0; i < n; i++)
                {
                    arrC[i] = (Entities.Thue)arr[i];
                }
            }
            catch (Exception ex)
            { string s = ex.Message.ToString(); }
            finally
            {
                cmd.Connection.Dispose();
                cn.Close();
                conn.closeConnection();
            }

            return(arrC);
        }
Example #5
0
        /// <summary>
        /// Select Bảng
        /// </summary>
        /// <returns></returns>
        public Entities.Thue[] Select()
        {
            Sql = new Constants.Sql();
            pt  = new Constants.Thue();
            string        sql  = Sql.SelectAllThue;
            Connection    conn = new Connection();
            SqlConnection cn   = conn.openConnection();
            SqlCommand    cmd  = new SqlCommand(sql, cn);
            SqlDataReader dr   = cmd.ExecuteReader(CommandBehavior.CloseConnection);

            //Insert Category into ArrayList
            ArrayList arr = new ArrayList();

            while (dr.Read())
            {
                Entities.Thue phieuthu = new Entities.Thue();
                phieuthu.ThueID     = Convert.ToInt32(dr[pt.ThueID].ToString());
                phieuthu.MaThue     = dr[pt.MaThue].ToString();
                phieuthu.TenThue    = dr[pt.TenThue].ToString();
                phieuthu.GiaTriThue = dr["GiaTriThue"].ToString();
                phieuthu.GhiChu     = dr[pt.GhiChu].ToString();
                phieuthu.Deleted    = (Boolean)dr[pt.Deleted];
                arr.Add(phieuthu);
            }
            int n = arr.Count;

            if (n == 0)
            {
                return(null);
            }

            Entities.Thue[] arrC = new Entities.Thue[n];
            for (int i = 0; i < n; i++)
            {
                arrC[i] = (Entities.Thue)arr[i];
            }

            //Giai phong bo nho
            arr = null;
            cmd.Connection.Dispose();
            cn.Close();
            conn.closeConnection();
            cn   = null;
            conn = null;
            return(arrC);
        }
Example #6
0
        //delete
        public void Delete(Entities.Thue dvt1)
        {
            dvt = new Constants.ThueH();
            Entities.Thue loaihanghoa = new Entities.Thue();
            Sql = new Constants.Sql();
            string sql = Sql.DeleteThue;
            Connection conn = new Connection();
            SqlConnection cn = conn.openConnection();
            SqlCommand cmd = new SqlCommand(sql, cn);
            cmd.Parameters.Add(dvt.HanhDong, SqlDbType.NVarChar, 20).Value = dvt1.HanhDong;
            cmd.Parameters.Add(dvt.ThueID, SqlDbType.Int).Value = dvt1.ThueID;

            cmd.ExecuteNonQuery();
            cmd.Connection.Dispose();
            cn.Close();
            conn.closeConnection();
            cn = null;
            conn = null;
        }
Example #7
0
        //delete
        public void Delete(Entities.Thue dvt1)
        {
            dvt = new Constants.ThueH();
            Entities.Thue loaihanghoa = new Entities.Thue();
            Sql = new Constants.Sql();
            string        sql  = Sql.DeleteThue;
            Connection    conn = new Connection();
            SqlConnection cn   = conn.openConnection();
            SqlCommand    cmd  = new SqlCommand(sql, cn);

            cmd.Parameters.Add(dvt.HanhDong, SqlDbType.NVarChar, 20).Value = dvt1.HanhDong;
            cmd.Parameters.Add(dvt.ThueID, SqlDbType.Int).Value            = dvt1.ThueID;

            cmd.ExecuteNonQuery();
            cmd.Connection.Dispose();
            cn.Close();
            conn.closeConnection();
            cn   = null;
            conn = null;
        }
Example #8
0
        public void KhoiTao()
        {
            try
            {
                Server_Client.Client client = new Server_Client.Client();
                Client1 = client.Connect(Luu.IP, Luu.Ports);
                CheckRefer ctxh = new CheckRefer("BanBuon");
                Clientstrem = client.SerializeObj(Client1, "Select", ctxh);
                selectall = (SelectAll)client.DeserializeHepper(Clientstrem, selectall);
                // gói hàng
                _goihang = selectall.GoiHang;
                // chi tiết gói hàng
                _chitietgoihang = selectall.ChiTietGoiHang;
                // quy đổi đơn vị tính
                _quidoidvt = selectall.QuyDoiDonViTinh;

                // lay hang hoa the kho
                client = new Server_Client.Client();
                // gán TCPclient
                Client1 = client.Connect(Luu.IP, Luu.Ports);
                client = new Server_Client.Client();

                TruyenGiaTri khoHang = (TruyenGiaTri)cbbkhohang.SelectedItem;
                string makho = khoHang.Giatritruyen;
                HangHoa kh = new HangHoa("SelectTheoKho", makho);
                Clientstrem = client.SerializeObj(Client1, "HangHoa", kh);
                HangHoa[] hhArr = new HangHoa[1];
                hhArr = (HangHoa[])client.DeserializeHepper1(Clientstrem, hhArr);

                if (hhArr == null)
                    _hangHoaTheoKho = new HangHoa[0];

                if (hhArr.Length <= 0) return;

                List<HangHoa> array = hhArr.ToList();

                HangHoa[] save = Common.Utilities.CheckGoiHang(hhArr, _goihang, _chitietgoihang);
                if (save != null) array.AddRange(save);

                // lay hang hoa theo kho
                _hangHoaTheoKho = array.ToArray();

                // Lay Thue
                client = new Server_Client.Client();

                Thue thueTemp = new Thue("Select");
                Clientstrem = client.SerializeObj(Client1, "Thue", thueTemp);
                _thue = new Thue[1];
                _thue = (Thue[])client.DeserializeHepper1(Clientstrem, _thue) ?? new Thue[0];
            }
            catch
            {
            }
        }
Example #9
0
        public void SelectThue()
        {
            client = new Server_Client.Client();
            this.tcpClient = client.Connect(Luu.IP, Luu.Ports);

            Entities.Thue lt = new Entities.Thue();
            lt = new Entities.Thue("Select");
            networkStream = client.SerializeObj(this.tcpClient, "Thue", lt);
            thue = new Entities.Thue[1];
            thue = (Entities.Thue[])client.DeserializeHepper1(networkStream, thue);
        }
Example #10
0
        //Lấy combobox thuế
        public void LayThue()
        {
            cbbThue.Items.Clear();
            client = new Server_Client.Client();
            this.tcpClient = client.Connect(Luu.IP, Luu.Ports);

            Entities.Thue nh = new Entities.Thue();
            nh = new Entities.Thue("Select");
            networkStream = client.SerializeObj(this.tcpClient, "Thue", nh);
            Entities.Thue[] nh1 = new Entities.Thue[1];
            nh1 = (Entities.Thue[])client.DeserializeHepper1(networkStream, nh1);
            if (nh1 != null)
            {
                cbbThue.DataSource = nh1;
                cbbThue.DisplayMember = "TenThue";
            }
        }
Example #11
0
        public Entities.Thue[] sp_SelectThuesAll()
        {
            Entities.Thue[] arrC = null;
            try
            {
                dvt = new Constants.ThueH();
                Sql = new Constants.Sql();
                string sql = Sql.SelectThue;
                conn = new Connection();
                cn = conn.openConnection();
                cmd = new SqlCommand(sql, cn);
                dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                arr = new ArrayList();
                while (dr.Read())
                {
                    donvitinh = new Entities.Thue();
                    donvitinh.ThueID = Convert.ToInt32(dr[dvt.ThueID].ToString());
                    donvitinh.MaThue = dr[dvt.MaThue].ToString();
                    donvitinh.GiaTriThue = dr[dvt.GiaTriThue].ToString();
                    donvitinh.TenThue = dr[dvt.TenThue].ToString();
                    donvitinh.GhiChu = dr[dvt.GhiChu].ToString();
                    donvitinh.Deleted = (Boolean)dr[dvt.Deleted];
                    arr.Add(donvitinh);
                }
                int n = arr.Count;
                if (n == 0) { return null; }
                arrC = new Entities.Thue[n];
                for (int i = 0; i < n; i++)
                {
                    arrC[i] = (Entities.Thue)arr[i];
                }
            }
            catch (Exception ex)
            { string s = ex.Message.ToString(); }
            finally
            {
                cmd.Connection.Dispose();
                cn.Close();
                conn.closeConnection();
            }

            return arrC;
        }