Пример #1
0
        public void insertOrder(ModelOrder data)
        {
            SqlConnection conn       = new SqlConnection(strConnect);
            string        cmdTextRaw = "INSERT INTO Product(ProductName,ProductPrice,ProductDatail,TypeID) VALUES ('" + data.ProductName + "'," + data.ProductPrice + ",'" + data.ProductDetail + "'," + data.TypeProduct + ")";

            Debug.WriteLine(cmdTextRaw);
            callDb(cmdTextRaw);
        }
Пример #2
0
        public void updateOrder(ModelOrder data, int id)
        {
            Debug.WriteLine("editOrder");

            SqlConnection conn    = new SqlConnection(strConnect);
            string        cmdEdit = "UPDATE Product SET " +
                                    "ProductName = '" + data.ProductName + "'," +
                                    "ProductPrice = " + data.ProductPrice + "," +
                                    "ProductDatail = '" + data.ProductPrice + "' " +
                                    // "TypeID = " + data.TypeProduct + " " +
                                    "WHERE ProductID = " + id + "";

            Debug.WriteLine(cmdEdit);
            callDb(cmdEdit);
        }
Пример #3
0
 protected void submit_Click(object sender, EventArgs e)
 {
     try
     {
         if (string.IsNullOrEmpty(productName.Text))
         {
             showAlertError("null Name", "not name");
             return;
         }
         if (string.IsNullOrEmpty(productPrice.Text))
         {
             showAlertError("null Price", "not price");
         }
         if (string.IsNullOrEmpty(productDetail.Text))
         {
             showAlertError("null Detail", "not detail");
         }
         if (string.IsNullOrEmpty(typeProduct.Text))
         {
             showAlertError("null type", "not insert data");
         }
         else
         {
             OrderRepro movieRepo = new OrderRepro();
             ModelOrder data      = new ModelOrder()
             {
                 ProductName   = Convert.ToString(productName.Text),
                 ProductPrice  = Convert.ToInt16(productPrice.Text),
                 ProductDetail = Convert.ToString(productDetail.Text),
                 TypeProduct   = Convert.ToInt16(typeProduct.Text),
             };
             movieRepo.insertOrder(data);
             showAlertSuccess("alertSuccess", "Insert success");
         }
     }
     catch (SqlException sqlEx)
     {
         showAlertError("alertSqlErr", sqlEx.Message);
     }
     catch (Exception ex)
     {
         showAlertError("alertErr", ex.Message);
     }
 }
Пример #4
0
 internal void updateOrder(ModelOrder data)
 {
     throw new NotImplementedException();
 }
Пример #5
0
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     try
     {
         // Validate
         string paramId = Request["id"];
         int    id      = 0;
         if (string.IsNullOrEmpty(paramId) || !int.TryParse(paramId, out id))
         {
             showAlertError("alertIdErr", "ไม่พบข้อมูลรายการภาพยนต์นี้");
             return;
         }
         else
         {
             id = int.Parse(paramId);
         }
         if (string.IsNullOrEmpty(productName.Text))
         {
             showAlertError("alertTitleErr", "กรุณากรอกชื่อภาพยนต์");
             return;
         }
         if (string.IsNullOrEmpty(productDetail.Text))
         {
             showAlertError("alertDurErr", "กรุณากรอกความยาว(นาที)");
             return;
         }
         int numDuration;
         if (!int.TryParse(productPrice.Text, out numDuration))
         {
             showAlertError("alertDurNotNumErr", "กรุณากรอกความยาว(นาที) ให้เป็นตัวเลขเท่านั้น");
             return;
         }
         numDuration = int.Parse(typeProduct.Text);
         if (numDuration > 200)
         {
             showAlertError("alertMoreThen200Min", "กรุณากรอกความยาว(นาที) น้อยกว่า 200 นาที");
             return;
         }
         else
         {
             OrderRepro movieRepo = new OrderRepro();
             ModelOrder data      = new ModelOrder()
             {
                 Id            = id,
                 ProductName   = Convert.ToString(productName.Text),
                 ProductPrice  = Convert.ToInt16(productPrice.Text),
                 ProductDetail = Convert.ToString(productDetail.Text),
                 //TypeProduct = Convert.ToInt16(typeProduct.Text),
             };
             Debug.WriteLine(data);
             Debug.WriteLine("update");
             movieRepo.updateOrder(data, id);
             Response.Redirect("~/OrderList.aspx");
         }
     }
     catch (SqlException sqlEx)
     {
         showAlertError("alertSqlErr", sqlEx.Message);
     }
     catch (Exception ex)
     {
         showAlertError("alertErr", ex.Message);
     }
 }