Пример #1
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);
     }
 }
Пример #2
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);
     }
 }