Esempio n. 1
0
        public static bool InsertSalesInfo(SalesInfoData infoData)
        {
            ProcessDBEvent dbEvent = delegate(ref SqlTransaction transaction)
            {
                using (SqlCommand command = DBCONN.CreateCommand())
                {
                    command.Transaction = transaction;
                    command.CommandText = DBCommands.insert_salesinfo_params;
                    command.Parameters.AddWithValue("SName", infoData.SName);                       // string
                    command.Parameters.AddWithValue("PostalCod", infoData.PostalCod);               // decimal
                    command.Parameters.AddWithValue("LoginTime", infoData.LoginTime);               // DateTime
                    command.Parameters.AddWithValue("PhotoCopierModel", infoData.PhotoCopierModel); // string
                    command.Parameters.AddWithValue("DemoDuration", infoData.DemoDuration);         // DateTime
                    command.Parameters.AddWithValue("Frequency", infoData.Frequency);               // int

                    bool result = false;
                    try
                    {
                        result = (command.ExecuteNonQuery() != 0);
                    }
                    catch (SqlException ex)
                    {
                        //Debug.Log(ex.Message);
                    }
                    catch (Exception ex)
                    {
                        //Debug.Log(ex.Message);
                    }

                    return(result);
                }
            };

            return(ProcessDB(dbEvent));
        }
Esempio n. 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.Request.HttpMethod == "POST")
            {
                // Read parameters
                //string json = (Request.Form["json"]);

                //string json;
                //using (var reader = new StreamReader(Request.InputStream))
                //{
                //    json = reader.ReadToEnd();
                //}

                //SalesInfoData data = JsonConvert.DeserializeObject<SalesInfoData>(json);

                string   SName            = Request.Form["SName"];
                decimal  PostalCod        = Convert.ToDecimal(Request.Form["PostalCod"]);
                DateTime?LoginTime        = Convert.ToDateTime(Request.Form["LoginTime"]);
                string   PhotoCopierModel = Request.Form["PhotoCopierModel"];
                TimeSpan?DemoDuration     = TimeSpan.Parse(Request.Form["DemoDuration"]);
                int      Frequency        = Convert.ToInt32(Request.Form["Frequency"]);

                SalesInfoData data = new SalesInfoData();
                data.SName            = SName;
                data.PostalCod        = PostalCod;
                data.LoginTime        = LoginTime;
                data.PhotoCopierModel = PhotoCopierModel;
                data.DemoDuration     = DemoDuration;
                data.Frequency        = Frequency;

                // Insert new sales info row with data provided
                bool result = DBManager.InsertSalesInfo(data);

                // Return result
                Response.Clear();
                Response.Write(result);
                Response.End();
            }
        }