Example #1
0
 /// <summary>
 /// Delete Bảng
 /// </summary>
 public bool Delete(Entities.SoDuCongNo pxh)
 {
     try
     {
         bool kt = false;
         pt  = new Constants.CongNo();
         Sql = new Constants.Sql();
         string        sql  = Sql.DeleteSoDuCongNo;
         Connection    conn = new Connection();
         SqlConnection cn   = conn.openConnection();
         SqlCommand    cmd  = new SqlCommand(sql, cn);
         cmd.Parameters.Add(pt.MaSoDuCongNo, SqlDbType.VarChar, 20).Value = pxh.MaSoDuCongNo;
         int i = cmd.ExecuteNonQuery();
         if (i == 1)
         {
             kt = true;
         }
         else
         {
             kt = false;
         }
         cmd.Connection.Dispose();
         cn.Close();
         conn.closeConnection();
         cn   = null;
         conn = null;
         return(kt);
     }
     catch
     {
         return(false);
     }
 }
Example #2
0
        /// <summary>
        /// Select Bảng
        /// </summary>
        /// <returns></returns>
        public Entities.SoDuCongNo[] Select()
        {
            try
            {
                Sql = new Constants.Sql();
                pt  = new Constants.CongNo();
                string        sql  = Sql.SelectSoDuCongNo;
                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.SoDuCongNo phieuthu = new Entities.SoDuCongNo();
                    phieuthu.SoDuCongNoID  = Convert.ToInt32(dr[pt.SoDuCongNoID].ToString());
                    phieuthu.MaSoDuCongNo  = dr[pt.MaSoDuCongNo].ToString();
                    phieuthu.MaDoiTuong    = dr[pt.MaDoiTuong].ToString();
                    phieuthu.TenDoiTuong   = dr[pt.TenDoiTuong].ToString();
                    phieuthu.DiaChi        = dr[pt.DiaChi].ToString();
                    phieuthu.SoDuDauKy     = dr[pt.SoDuDauKy].ToString();
                    phieuthu.NgayKetChuyen = DateTime.Parse(dr[pt.NgayKetChuyen].ToString());
                    phieuthu.SoDuCuoiKy    = dr[pt.SoDuCuoiKy].ToString();
                    phieuthu.LoaiDoiTuong  = Boolean.Parse(dr[pt.LoaiDoiTuong].ToString());
                    phieuthu.TrangThai     = Boolean.Parse(dr[pt.TrangThai].ToString());
                    arr.Add(phieuthu);
                }
                int n = arr.Count;
                if (n == 0)
                {
                    return(null);
                }

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

                //Giai phong bo nho
                return(arrC);
            }
            catch
            {
                return(null);
            }
        }
Example #3
0
 /// <summary>
 /// Insert Update Bảng
 /// </summary>
 public bool Insert(Entities.SoDuCongNo pxh)
 {
     try
     {
         bool kt = false;
         pt  = new Constants.CongNo();
         Sql = new Constants.Sql();
         string        sql  = Sql.InsertSoDuCongNo;
         Connection    conn = new Connection();
         SqlConnection cn   = conn.openConnection();
         SqlCommand    cmd  = new SqlCommand(sql, cn);
         cmd.Parameters.Add(pt.MaSoDuCongNo, SqlDbType.VarChar, 20).Value  = pxh.MaSoDuCongNo;
         cmd.Parameters.Add(pt.MaDoiTuong, SqlDbType.VarChar, 20).Value    = pxh.MaDoiTuong;
         cmd.Parameters.Add(pt.TenDoiTuong, SqlDbType.NVarChar, 200).Value = pxh.TenDoiTuong;
         cmd.Parameters.Add(pt.DiaChi, SqlDbType.NVarChar, 200).Value      = pxh.DiaChi;
         cmd.Parameters.Add(pt.SoDuDauKy, SqlDbType.Float).Value           = pxh.SoDuDauKy;
         cmd.Parameters.Add(pt.NgayKetChuyen, SqlDbType.DateTime).Value    = pxh.NgayKetChuyen;
         cmd.Parameters.Add(pt.SoDuCuoiKy, SqlDbType.Float).Value          = pxh.SoDuCuoiKy;
         cmd.Parameters.Add(pt.LoaiDoiTuong, SqlDbType.Bit).Value          = pxh.LoaiDoiTuong;
         cmd.Parameters.Add(pt.TrangThai, SqlDbType.Bit).Value             = pxh.TrangThai;
         int i = cmd.ExecuteNonQuery();
         if (i == 1)
         {
             kt = true;
         }
         else
         {
             kt = false;
         }
         cmd.Connection.Dispose();
         cn.Close();
         conn.closeConnection();
         cn   = null;
         conn = null;
         return(kt);
     }
     catch
     {
         return(false);
     }
 }