Пример #1
0
 /// <summary>
 /// Insert Update Bảng
 /// </summary>
 public bool UpdateTinhTrang(Entities.PhieuXuatHuy pxh)
 {
     try
     {
         bool kt = false;
         pt  = new Constants.PhieuXuatHuy();
         Sql = new Constants.Sql();
         string        sql  = Sql.UpdateTinhTrang;
         Connection    conn = new Connection();
         SqlConnection cn   = conn.openConnection();
         SqlCommand    cmd  = new SqlCommand(sql, cn);
         cmd.Parameters.Add(pt.MaPhieuXuatHuy, SqlDbType.VarChar, 20).Value = pxh.MaPhieuXuatHuy;
         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);
     }
 }
Пример #2
0
        public Entities.PhieuXuatHuy[] SelectTheoMaKho(string MaKho)
        {
            SelectNV();
            pt = new Constants.PhieuXuatHuy();
            string sql = "";

            sql = "Select * from PhieuXuatHuy where MaKho='" + MaKho + "' and deleted=0";
            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.PhieuXuatHuy phieuxuathuy = new Entities.PhieuXuatHuy();
                phieuxuathuy.PhieuXuatHuyID = Convert.ToInt32(dr[pt.PhieuXuatHuyID].ToString());
                phieuxuathuy.MaPhieuXuatHuy = dr[pt.MaPhieuXuatHuy].ToString();
                phieuxuathuy.NgayLap        = Convert.ToDateTime(dr[pt.NgayLap].ToString());
                phieuxuathuy.MaNhanVien     = dr[pt.MaNhanVien].ToString();
                phieuxuathuy.TenNhanVien    = TimTenNV(phieuxuathuy.MaNhanVien);
                phieuxuathuy.MaKho          = dr[pt.MaKho].ToString();
                phieuxuathuy.TrangThai      = (Boolean)dr[pt.TrangThai];
                phieuxuathuy.Tongtien       = dr[pt.Tongtien].ToString();
                phieuxuathuy.GhiChu         = dr[pt.GhiChu].ToString();
                phieuxuathuy.Deleted        = (Boolean)dr[pt.Deleted];
                arr.Add(phieuxuathuy);
            }
            int n = arr.Count;

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

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

            //Giai phong bo nho
            arr = null;
            cmd.Connection.Dispose();
            cn.Close();
            conn.closeConnection();
            cn   = null;
            conn = null;
            return(arrC);
        }
Пример #3
0
        /// <summary>
        /// Insert Update Bảng
        /// </summary>
        public bool InsertUpdate(Entities.PhieuXuatHuy pxh)
        {
            try
            {
                bool kt = false;
                pt  = new Constants.PhieuXuatHuy();
                Sql = new Constants.Sql();
                string        sql  = Sql.InsertUpdatePhieuXuatHuy;
                Connection    conn = new Connection();
                SqlConnection cn   = conn.openConnection();
                SqlCommand    cmd  = new SqlCommand(sql, cn);
                cmd.Parameters.Add(pt.HanhDong, SqlDbType.NVarChar, 20).Value       = pxh.HanhDong;
                cmd.Parameters.Add(pt.PhieuXuatHuyID, SqlDbType.Int).Value          = pxh.PhieuXuatHuyID;
                cmd.Parameters.Add(pt.MaPhieuXuatHuy, SqlDbType.NVarChar, 20).Value = pxh.MaPhieuXuatHuy;
                cmd.Parameters.Add(pt.NgayLap, SqlDbType.DateTime).Value            = pxh.NgayLap;
                cmd.Parameters.Add(pt.MaNhanVien, SqlDbType.NVarChar, 20).Value     = pxh.MaNhanVien;
                cmd.Parameters.Add(pt.MaKho, SqlDbType.NVarChar, 20).Value          = pxh.MaKho;
                cmd.Parameters.Add(pt.TrangThai, SqlDbType.Bit).Value        = pxh.TrangThai;
                cmd.Parameters.Add(pt.Tongtien, SqlDbType.Money).Value       = pxh.Tongtien;
                cmd.Parameters.Add(pt.GhiChu, SqlDbType.NVarChar, 100).Value = pxh.GhiChu;
                cmd.Parameters.Add(pt.Deleted, SqlDbType.Bit).Value          = pxh.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
            {
                return(false);
            }
        }
        public void LayPhieuXuatHuy()
        {
            try
            {

                cl = new Server_Client.Client();
                this.client1 = cl.Connect(Luu.IP, Luu.Ports);
                Entities.PhieuXuatHuy ctxh = new Entities.PhieuXuatHuy("Select");
                clientstrem = cl.SerializeObj(this.client1, "PhieuXuatHuy", ctxh);
                Entities.PhieuXuatHuy[] PXuatHuy1 = new Entities.PhieuXuatHuy[0];
                PXuatHuy1 = (Entities.PhieuXuatHuy[])cl.DeserializeHepper1(clientstrem, PXuatHuy1);
                if (PXuatHuy1 == null)
                {
                    PXuatHuy1 = new Entities.PhieuXuatHuy[0];
                    PXuatHuy = PXuatHuy1;
                    return;
                }

                int count = 0;
                for (int i = 0; i < PXuatHuy1.Length; i++)
                {
                    DateTime ngaylap = PXuatHuy1[i].NgayLap;
                    if (ngaylap >= BatDau && ngaylap <= KetThuc)
                    {
                        count++;
                    }
                }
                PXuatHuy = new Entities.PhieuXuatHuy[count];
                count = 0;
                for (int i = 0; i < PXuatHuy1.Length; i++)
                {
                    DateTime ngaylap = PXuatHuy1[i].NgayLap;
                    if (ngaylap >= BatDau && ngaylap <= KetThuc)
                    {
                        PXuatHuy[count] = PXuatHuy1[i];
                        count++;
                    }
                }

            }
            catch
            {
            }
        }
Пример #5
0
        public Entities.PhieuXuatHuy[] SelectTheoMaKho(string MaKho)
        {
            SelectNV();
            pt = new Constants.PhieuXuatHuy();
            string sql = "";
            sql = "Select * from PhieuXuatHuy where MaKho='" + MaKho + "' and deleted=0";
            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.PhieuXuatHuy phieuxuathuy = new Entities.PhieuXuatHuy();
                phieuxuathuy.PhieuXuatHuyID = Convert.ToInt32(dr[pt.PhieuXuatHuyID].ToString());
                phieuxuathuy.MaPhieuXuatHuy = dr[pt.MaPhieuXuatHuy].ToString();
                phieuxuathuy.NgayLap = Convert.ToDateTime(dr[pt.NgayLap].ToString());
                phieuxuathuy.MaNhanVien = dr[pt.MaNhanVien].ToString();
                phieuxuathuy.TenNhanVien = TimTenNV(phieuxuathuy.MaNhanVien);
                phieuxuathuy.MaKho = dr[pt.MaKho].ToString();
                phieuxuathuy.TrangThai = (Boolean)dr[pt.TrangThai];
                phieuxuathuy.Tongtien = dr[pt.Tongtien].ToString();
                phieuxuathuy.GhiChu = dr[pt.GhiChu].ToString();
                phieuxuathuy.Deleted = (Boolean)dr[pt.Deleted];
                arr.Add(phieuxuathuy);
            }
            int n = arr.Count;
            if (n == 0) return null;

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

            //Giai phong bo nho
            arr = null;
            cmd.Connection.Dispose();
            cn.Close();
            conn.closeConnection();
            cn = null;
            conn = null;
            return arrC;
        }