Example #1
0
        /// <summary>
        /// Select Bảng
        /// </summary>
        /// <returns></returns>
        public Entities.ChiTietXuatHuy[] Select(Entities.ChiTietXuatHuy ctxh2)
        {
            Sql  = new Constants.Sql();
            ctxh = new Constants.ChiTietXuatHuy();
            string        sql  = Sql.SelectChiTietXuatHuy;
            Connection    conn = new Connection();
            SqlConnection cn   = conn.openConnection();
            SqlCommand    cmd  = new SqlCommand(sql, cn);

            cmd.Parameters.Add(ctxh.MaPhieuXuatHuy, SqlDbType.VarChar, 20).Value = ctxh2.MaPhieuXuatHuy;
            SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);

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

            while (dr.Read())
            {
                Entities.ChiTietXuatHuy ctxh1 = new Entities.ChiTietXuatHuy();
                ctxh1.MaPhieuXuatHuy = dr[ctxh.MaPhieuXuatHuy].ToString();
                ctxh1.MaHangHoa      = dr[ctxh.MaHangHoa].ToString();
                ctxh1.SoLuong        = (int)dr[ctxh.SoLuong];
                ctxh1.GhiChu         = dr[ctxh.GhiChu].ToString();
                ctxh1.Deleted        = (Boolean)dr[ctxh.Deleted];
                arr.Add(ctxh1);
            }
            int n = arr.Count;

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

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

            //Giai phong bo nho
            arr = null;
            cmd.Connection.Dispose();
            cn.Close();
            conn.closeConnection();
            cn   = null;
            conn = null;
            return(arrC);
        }
Example #2
0
        /// <summary>
        /// Insert Update Bảng
        /// </summary>
        public bool InsertUpdate(Entities.ChiTietXuatHuy ctxh1)
        {
            try
            {
                bool kt = false;
                ctxh = new Constants.ChiTietXuatHuy();
                Sql  = new Constants.Sql();
                string        sql  = Sql.InsertUpdateChiTietXuatHuyMang;
                Connection    conn = new Connection();
                SqlConnection cn   = conn.openConnection();
                SqlCommand    cmd  = new SqlCommand(sql, cn);

                cmd.Parameters.Add(ctxh.HanhDong, SqlDbType.VarChar, 20).Value       = ctxh1.HanhDong;
                cmd.Parameters.Add(ctxh.MaPhieuXuatHuy, SqlDbType.VarChar, 20).Value = ctxh1.MaPhieuXuatHuy;
                cmd.Parameters.Add(ctxh.MaHangHoa, SqlDbType.VarChar, 50).Value      = ctxh1.MaHangHoa;
                cmd.Parameters.Add(ctxh.SoLuong, SqlDbType.Int, 20).Value            = ctxh1.SoLuong;
                cmd.Parameters.Add(ctxh.GhiChu, SqlDbType.NVarChar, 20).Value        = ctxh1.GhiChu;
                cmd.Parameters.Add(ctxh.Deleted, SqlDbType.Bit).Value = ctxh1.Deleted;

                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 (Exception ex)
            {
                string s = ex.Message;
                return(false);
            }
        }