Exemple #1
0
        private string PhatSinhSerial()
        {
            string        strSoSerial = string.Empty;
            SqlConnection conn        = ThaoTacDuLieu.TaoVaMoKetNoi();
            SqlDataReader dr          = null;

            do
            {
                if (dr != null)
                {
                    dr.Close();
                }
                strSoSerial = TienIch.GenerateSerial(12);
                string     query = string.Format("select * from Serial where SoSerial='{0}'", strSoSerial);
                SqlCommand cmd   = new SqlCommand(query, conn);
                dr = cmd.ExecuteReader();
            } while (dr.HasRows);
            ThaoTacDuLieu.DongKetNoi(conn);
            return(strSoSerial);
        }
Exemple #2
0
        public bool ThemSoLuongSP(string strMaSP, int SL)
        {
            string queryUpdateSP = string.Format("update SanPham set SoLuong={1} where MaSanPham='{0}'", strMaSP, SL);

            if (ThaoTacDuLieu.ThucThi(queryUpdateSP))
            {
                int SoDong = 0;
                for (int i = 0; i < SL; i++)
                {
                    string SoSR = TienIch.GenerateSerial(12);
                    SoDong = ThaoTacDuLieu.DemSoDongCuaBang("Serial");
                    string MaSR = "SER" + (SoDong + 1);
                    ThaoTacDuLieu.ThucThi(string.Format("insert into Serial values('{0}','{1}',NULL,'{2}',NULL,{3})", MaSR, SoSR, strMaSP, 1));
                }

                return(true);
            }
            else
            {
                return(false);
            }
        }