Example #1
0
        public int Insert(ProductSell info, List <ProductSellRecord> records)
        {
            try
            {
                //string commandText = @"insert into Users(userName,userPassword,userLevel,userPhone,userAddress) values (
                //?userName,?userPassword,?userLevel,?userPhone,?userAddress)";

                string commandText = string.Format("insert into ProductSell(name, sellTime, comment, status, customerID) values('{0}', '{1}', '{2}', '{3}', {4})", info.Name, info.SellTime, info.Comment, info.Status, info.CustomerID);

                DbHelperAccess.executeNonQuery(commandText);

                int ProductSellID = DbHelperAccess.executeMax("ID", "ProductSell");

                ProductSellRecordDao dao = new ProductSellRecordDao();
                foreach (ProductSellRecord record in records)
                {
                    record.SellID = ProductSellID;
                    dao.Insert(record);
                }
                return(ProductSellID);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 public static ProductSellRecordDao getInstance()
 {
     if (dao == null)
     {
         dao = new ProductSellRecordDao();
     }
     return(dao);
 }
Example #3
0
        public void Update(ProductSell info, List <ProductSellRecord> records)
        {
            string commandText = string.Format("update ProductSell set name='{0}', sellTime='{1}', comment='{2}', customerID='{3}' where ID={4}",
                                               info.Name, info.SellTime, info.Comment, info.CustomerID, info.ID);

            DbHelperAccess.executeNonQuery(commandText);

            ProductSellRecordDao.getInstance().DeleteBySellID(info.ID);

            foreach (ProductSellRecord record in records)
            {
                record.SellID = info.ID;
                ProductSellRecordDao.getInstance().Insert(record);
            }
        }