Пример #1
0
        /// <summary>
        /// Hàm lấy nhacungcap theo mã
        /// </summary>
        /// <returns>Trả về objnhacungcap </returns>
        public nhacungcap GetByID(string strid)
        {
            nhacungcap objnhacungcap = new nhacungcap();
            string     strFun        = "fn_nhacungcap_getobjbyid";

            try
            {
                NpgsqlParameter[] prmArr = new NpgsqlParameter[1];

                prmArr[0]       = new NpgsqlParameter("id", NpgsqlDbType.Varchar);
                prmArr[0].Value = strid;

                DataSet dsnhacungcap = mDataAccess.ExecuteDataSet(strFun, CommandType.StoredProcedure, prmArr);

                if ((dsnhacungcap != null) && (dsnhacungcap.Tables.Count > 0))
                {
                    if (dsnhacungcap.Tables[0].Rows.Count > 0)
                    {
                        DataRow dr = dsnhacungcap.Tables[0].Rows[0];
                        objnhacungcap.id = dr["id"].ToString();

                        objnhacungcap.ten = dr["ten"].ToString();

                        objnhacungcap.diachi = dr["diachi"].ToString();

                        objnhacungcap.dienthoai = dr["dienthoai"].ToString();

                        objnhacungcap.ghichu = dr["ghichu"].ToString();

                        try{ objnhacungcap.daxoa = Convert.ToInt32("0" + dr["daxoa"].ToString()); }
                        catch { objnhacungcap.daxoa = 0; }


                        return(objnhacungcap);
                    }

                    return(null);
                }

                return(null);
            }
            catch
            {
                return(null);
            }
        }
Пример #2
0
        /// <summary>
        /// Thêm mới dữ liệu vào bảng: nhacungcap
        /// </summary>
        /// <param name="obj">objnhacungcap</param>
        /// <returns>Trả về trắng: Thêm mới thành công; Trả về khác trắng: Thêm mới không thành công</returns>
        public string Insert(nhacungcap objnhacungcap)
        {
            string strProc = "fn_nhacungcap_insert";

            try
            {
                NpgsqlParameter[] prmArr = new NpgsqlParameter[7];

                prmArr[0]       = new NpgsqlParameter("id", NpgsqlDbType.Varchar);
                prmArr[0].Value = objnhacungcap.strid;

                prmArr[1]       = new NpgsqlParameter("ten", NpgsqlDbType.Varchar);
                prmArr[1].Value = objnhacungcap.strten;

                prmArr[2]       = new NpgsqlParameter("diachi", NpgsqlDbType.Varchar);
                prmArr[2].Value = objnhacungcap.strdiachi;

                prmArr[3]       = new NpgsqlParameter("dienthoai", NpgsqlDbType.Varchar);
                prmArr[3].Value = objnhacungcap.strdienthoai;

                prmArr[4]       = new NpgsqlParameter("ghichu", NpgsqlDbType.Varchar);
                prmArr[4].Value = objnhacungcap.strghichu;

                prmArr[5]       = new NpgsqlParameter("daxoa", NpgsqlDbType.Integer);
                prmArr[5].Value = objnhacungcap.intdaxoa;

                prmArr[6]           = new NpgsqlParameter("ireturn", NpgsqlDbType.Text);
                prmArr[6].Direction = ParameterDirection.Output;

                mDataAccess.ExecuteQuery(strProc, CommandType.StoredProcedure, prmArr);

                string sKQ = prmArr[6].Value.ToString().Trim();

                if (sKQ.ToUpper().Equals("Add".ToUpper()) == true)
                {
                    return("");
                }
                return("Thêm mới dữ liệu không thành công");
            }
            catch (Exception ex)
            {
                return("Thêm mới dữ liệu không thành công. Chi Tiết: " + ex.Message);
            }
        }
Пример #3
0
        /// <summary>
        /// Hàm lấy danh sách objnhacungcap
        /// </summary>
        /// <param name="recperpage">Số lượng bản ghi kiểu integer</param>
        /// <param name="pageindex">Số trang kiểu integer</param>
        /// <returns>Trả về List<<nhacungcap>></returns>
        public List <nhacungcap> GetListPaged(int recperpage, int pageindex)
        {
            List <nhacungcap> list   = new List <nhacungcap>();
            string            strFun = "fn_nhacungcap_getpaged";

            try
            {
                NpgsqlParameter[] prmArr = new NpgsqlParameter[2];
                prmArr[0]       = new NpgsqlParameter("recperpage", NpgsqlDbType.Integer);
                prmArr[0].Value = recperpage;
                prmArr[1]       = new NpgsqlParameter("pageindex", NpgsqlDbType.Integer);
                prmArr[1].Value = pageindex;
                DataSet dsnhacungcap = mDataAccess.ExecuteDataSet(strFun, CommandType.StoredProcedure, prmArr);
                if ((dsnhacungcap != null) && (dsnhacungcap.Tables.Count > 0))
                {
                    for (int i = 0; i < dsnhacungcap.Tables[0].Rows.Count; i++)
                    {
                        nhacungcap objnhacungcap = new nhacungcap();
                        DataRow    dr            = dsnhacungcap.Tables[0].Rows[i];
                        objnhacungcap.id = dr["id"].ToString();

                        objnhacungcap.ten = dr["ten"].ToString();

                        objnhacungcap.diachi = dr["diachi"].ToString();

                        objnhacungcap.dienthoai = dr["dienthoai"].ToString();

                        objnhacungcap.ghichu = dr["ghichu"].ToString();

                        try{ objnhacungcap.daxoa = Convert.ToInt32("0" + dr["daxoa"].ToString()); }
                        catch { objnhacungcap.daxoa = 0; }

                        list.Add(objnhacungcap);
                    }
                    return(list);
                }
                return(null);
            }
            catch
            {
                return(null);
            }
        }
Пример #4
0
        /// <summary>
        /// Hàm lấy tất cả dữ liệu trong bảng nhacungcap
        /// </summary>
        /// <returns>Trả về List<<nhacungcap>></returns>
        public List <nhacungcap> GetList()
        {
            List <nhacungcap> list   = new List <nhacungcap>();
            string            strFun = "fn_nhacungcap_getall";

            try
            {
                DataSet dsnhacungcap = mDataAccess.ExecuteDataSet(strFun, CommandType.StoredProcedure);
                if ((dsnhacungcap != null) && (dsnhacungcap.Tables.Count > 0))
                {
                    for (int i = 0; i < dsnhacungcap.Tables[0].Rows.Count; i++)
                    {
                        nhacungcap objnhacungcap = new nhacungcap();
                        DataRow    dr            = dsnhacungcap.Tables[0].Rows[i];
                        objnhacungcap.id = dr["id"].ToString();

                        objnhacungcap.ten = dr["ten"].ToString();

                        objnhacungcap.diachi = dr["diachi"].ToString();

                        objnhacungcap.dienthoai = dr["dienthoai"].ToString();

                        objnhacungcap.ghichu = dr["ghichu"].ToString();

                        try{ objnhacungcap.daxoa = Convert.ToInt32("0" + dr["daxoa"].ToString()); }
                        catch { objnhacungcap.daxoa = 0; }

                        list.Add(objnhacungcap);
                    }
                    return(list);
                }
                return(null);
            }
            catch
            {
                return(null);
            }
        }