Ejemplo n.º 1
0
        public static bool AddDetailToUserBasket(string userName, Parameters.DetailInfo detail)
        {
            SqlConnection conn = new SqlConnection();
            string        request;

            try
            {
                request = String.Format("INSERT INTO dbo.Baskets (detai_price, " +
                                        "user_name, detail_name, detail_manuf, " +
                                        "detail_searchId, detail_Storage, " +
                                        "detail_Delivery, detail_PartId, " +
                                        "detail_baseCount, detail_Code, date_of_Upload_detail, hash) VALUES" +
                                        "({0},'{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}')",
                                        detail.Price.ToString(CultureInfo.InvariantCulture).Replace(",", "."), userName, detail.Name, detail.Manuf, detail.SearchID, detail.Storage, detail.Delivery,
                                        detail.PartId, detail.BaseCount,
                                        detail.Code, detail.DateofPlacetoBasket, Manage.CalculateBasketDetailHash(detail));
                DatabaseControl dbctrl = new DatabaseControl();
                SqlDataReader   rd     = dbctrl.GetDataFromDB(request, out conn);
                if (rd.Read())
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
                Singleton <Logger> .Instance.WriteMainLine("UserModels:SetDetailToUserBasket:" + ex.Message);

                return(false);
            }
            finally
            {
                conn.Close();
            }
            return(true);
        }