예제 #1
0
 private void btnSaveDate_Click(object sender, EventArgs e)
 {
     if (db.conn.State == ConnectionState.Closed)
     {
         db.conn.Open();
     }
     try
     {
         if (txtShopID.Text == "")
         {
             newMessagebox.warring("คุณยังไม่ใด้เลือกร้านเกมส์ที่นัดหมาย");
         }
         else
         {
             if (db.ChackDateAppointment(Convert.ToInt32(txtID.Text)) == true)
             {
                 using (SqlCommand cmd = new SqlCommand("InsertDateAppointment", db.conn))
                 {
                     cmd.CommandType = CommandType.StoredProcedure;
                     cmd.Parameters.AddWithValue("@ID", Convert.ToInt32(txtID.Text));
                     cmd.Parameters.AddWithValue("@ShopID", txtShopID.Text);
                     cmd.Parameters.AddWithValue("DateAppointment", Convert.ToDateTime(DateAppointment.Value.Date.ToString("dd-MM-yyyy")));
                     cmd.Parameters.AddWithValue("@ShopStatus", ShopStatusID);
                     cmd.ExecuteNonQuery();
                     newMessagebox.info("เพิ่มวันที่นัดหมายกับร้าน " + txtShopName.Text + " เรียบร้อยแล้ว   วันที่จะไปคือ " + DateAppointment.Value.Date.ToString("dd-MM-yyyy"));
                 }
             }
             else
             {
                 newMessagebox.warring("คุณใด้ทำการนัดวันที่กับทางร้าน " + txtShopName.Text + " ก่อนหน้านี้แล้ว");
             }
         }
     }
     catch (SqlException ex) { newMessagebox.error("SQL Error " + ex.ToString()); }
     catch (Exception ex) { newMessagebox.error("Exception Error " + ex.ToString()); }
     finally { db.conn.Close(); }
 }
예제 #2
0
 private void btnEditDate_Click(object sender, EventArgs e)
 {
     if (db.conn.State == ConnectionState.Closed)
     {
         db.conn.Open();
     }
     try
     {
         if (string.IsNullOrEmpty(txtShopID.Text))
         {
             newMessagebox.warring("คุณยังไม่ใด้เลือกร้านเกมส์ที่นัดหมาย");
         }
         else
         {
             if (db.ChackDateAppointment(Convert.ToInt32(txtID.Text)) == false)
             {
                 using (SqlCommand cmd = new SqlCommand("UpdateDateAppointment", db.conn))
                 {
                     cmd.CommandType = CommandType.StoredProcedure;
                     cmd.Parameters.AddWithValue("@ID", Convert.ToInt32(txtID.Text));
                     cmd.Parameters.AddWithValue("@ShopID", txtShopID.Text);
                     cmd.Parameters.AddWithValue("@DateAppointment", Convert.ToDateTime(dateTimePickerAll.Value.Date.ToString("dd-MM-yyyy")));
                     cmd.ExecuteNonQuery();
                     newMessagebox.info("ทำการแก้ใขวันนัดหมายกับทางร้าน " + txtShopName.Text + " แล้ว   แก้ใขเป็นวันที่ " + dateTimePickerAll.Value.Date.ToString("dd-MM-yyyy"));
                     BindData();
                     MountCalederBold();
                 }
             }
             else
             {
                 newMessagebox.warring("ไม่สามารถแก้ใขวันที่  เนื่องจากคุณยังไม่ใด้กำหนดวันนัดหมาย");
             }
         }
     }
     catch (SqlException ex) { newMessagebox.error("SQL Error " + ex.ToString()); }
     catch (Exception ex) { newMessagebox.error("Exception Error " + ex.ToString()); }
     finally { db.conn.Close(); }
 }