<window x:class="Bodymattergym.exercise_machine" xmlns:x="#unknown">
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350.522" Width="525.433" >
<grid x:name="txtsname" removed="#FF9A9AB4" rendertransformorigin="0.482,0.444" height="321" verticalalignment="Bottom" horizontalalignment="Left" width="515">
<textbox x:name="textmid" horizontalalignment="Left" height="23" textwrapping="Wrap" verticalalignment="Top" width="120" margin="145,78,0,0" />
<textbox x:name="textmprice" horizontalalignment="Left" height="23" textwrapping="Wrap" verticalalignment="Top" width="120" margin="145,134,0,0" />
<textblock x:name="txtmacname" horizontalalignment="Left" textwrapping="Wrap" text="Machine Name:" verticalalignment="Top" margin="31,111,0,0" fontsize="14" />
<textblock x:name="txtmacid" horizontalalignment="Left" textwrapping="Wrap" text="Machine Id:" verticalalignment="Top" margin="31,83,0,0" fontsize="14" />
<textblock x:name="txtmacprice" horizontalalignment="Left" textwrapping="Wrap" text="Machine Price:" verticalalignment="Top" margin="31,139,0,0" fontsize="14" />
<textblock x:name="txtmacpaymentstatus" horizontalalignment="Left" margin="31,214,0,0" textwrapping="Wrap" verticalalignment="Top"><run fontsize="14" text="Payment Status:" /></textblock>
<textblock x:name="txtdate" horizontalalignment="Left" margin="31,238,0,0" textwrapping="Wrap" verticalalignment="Top"><run fontsize="14" text="Delivery Date:" /></textblock>
<datepicker x:name="textmdate" horizontalalignment="Left" margin="145,235,0,0" verticalalignment="Top" />
<radiobutton groupname="Delivery" content="Yes" horizontalalignment="Left" verticalalignment="Top" margin="146,285,0,0" ischecked="True" fontsize="14" checked="RadioButton_Checked" />
<radiobutton groupname="Delivery" content="No" horizontalalignment="Left" margin="188,285,0,0" verticalalignment="Top" fontsize="14" checked="RadioButton_Checked_1" />
<textblock x:name="txtdeliverystatus" horizontalalignment="Left" textwrapping="Wrap" text="Delivery Status:" verticalalignment="Top" margin="31,286,0,0" fontsize="14" />
<radiobutton groupname="Pay" content="Advance" horizontalalignment="Left" verticalalignment="Top" ischecked="True" margin="149,218,0,0" fontsize="12" checked="RadioButton_Checked9" />
<radiobutton groupname="Pay" content="Full" horizontalalignment="Left" verticalalignment="Top" margin="283,218,0,0" fontsize="12" checked="RadioButton_Checked_8" />
<radiobutton groupname="Pay" content="Balance" horizontalalignment="Left" verticalalignment="Top" margin="214,218,0,0" fontsize="12" checked="RadioButton_Checked_6" />
<combobox x:name="ComboBox1" verticalalignment="Center" width="120" height="23" margin="145,106,250,192" horizontalalignment="Center" iseditable="False" selectionchanged="ComboBox1_SelectionChanged">
<comboboxitem>
<checkbox x:name="chklegpress" content="LegPress" />
</comboboxitem>
<comboboxitem>
<checkbox x:name="chkchestpress" content="ChestPress" />
</comboboxitem>
<comboboxitem>
<checkbox x:name="chkbutterfly" content="Butterlfy" />
</comboboxitem>
<comboboxitem>
<checkbox x:name="chkwingspully" content="WingsPully" />
</comboboxitem>
<comboboxitem>
<checkbox x:name="chkwingsrowing" content="WingsRowing" />
</comboboxitem>
<comboboxitem>
<checkbox x:name="chkcomondo" content="Comondo" />
</comboboxitem>
</combobox>
<Button Content="Submit" Height="23" HorizontalAlignment="Left" Margin="360,102,0,0" x:Name="Submit" VerticalAlignment="Top" Width="76" Click="Submit_Click" Background="#FF8F9AAB" FontSize="14" />
<textblock height="20" horizontalalignment="Left" margin="31,54,0,0" x:name="errormessage" verticalalignment="Top" width="247" opacitymask="Crimson" foreground="#FFE5572C" />
<richtextbox horizontalalignment="Left" width="299" margin="104,10,0,0" fontsize="24" fontfamily="Britannic Bold" fontweight="Bold" removed="#FF9A9AB4" foreground="#FF54677F" textchanged="RichTextBox_TextChanged_1" height="39" verticalalignment="Top">
<richtextbox.borderbrush>
<lineargradientbrush endpoint="0,20" mappingmode="Absolute" startpoint="0,0">
<gradientstop color="#FFABADB3" offset="0.05" />
<gradientstop color="#FFE2E3EA" offset="0.07" />
<gradientstop color="#FF54677F" offset="1" />
</lineargradientbrush>
</richtextbox.borderbrush>
<flowdocument>
<paragraph>
<run text=" Gym Equipments Form" />
</paragraph>
</flowdocument>
</richtextbox>
<Button Content="Status" Height="23" HorizontalAlignment="Left" Margin="360,162,0,0" x:Name="Status" VerticalAlignment="Top" Width="76" Click="Status_Click" Background="#FF8F9AAB" FontSize="14" />
<textblock x:name="txtgymname" horizontalalignment="Left" margin="31,163,0,0" textwrapping="Wrap" text="Gym Name:" verticalalignment="Top" rendertransformorigin="0.497,1.128" fontsize="14" />
<textbox x:name="textmgymname" horizontalalignment="Left" height="23" margin="145,162,0,0" textwrapping="Wrap" verticalalignment="Top" width="120" />
<textblock x:name="txtdelAdresses" horizontalalignment="Left" margin="31,260,0,0" textwrapping="Wrap" text="Delivery Address:" verticalalignment="Top" rendertransformorigin="0.497,1.128" fontsize="14" height="26" />
<textbox x:name="textmdeladd" horizontalalignment="Left" height="23" margin="145,259,0,0" textwrapping="Wrap" verticalalignment="Top" width="120" />
<textblock x:name="txtpayment" horizontalalignment="Left" margin="31,187,0,0" textwrapping="Wrap" text="Payment:" verticalalignment="Top" rendertransformorigin="0.497,1.128" fontsize="14" height="26" />
<textbox x:name="textmpayment" horizontalalignment="Left" height="23" margin="145,190,0,0" textwrapping="Wrap" verticalalignment="Top" width="120" />
<Button Content="Back" Height="23" HorizontalAlignment="Left" Margin="360,220,0,0" x:Name="Back_Copy" VerticalAlignment="Top" Width="76" Click="Back_Click" Background="#FF8F9AAB" FontSize="14" />
</grid>
</window>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Data;
using System.Data.SqlClient;
using System.Text.RegularExpressions;
namespace Bodymattergym
{
public partial class exercise_machine : Window
{
public exercise_machine()
{
InitializeComponent();
}
string dbconnection = (@"Data Source=EMIII-PC;
Initial Catalog=gymdatabase;
Integrated Security=True");
string ps;
string ds;
private void Back_Click(object sender, RoutedEventArgs e)
{
Window1 mac = new Window1();
this.Close();
mac.ShowDialog();
}
private void Submit_Click(object sender, RoutedEventArgs e)
{
using (SqlConnection conn = new SqlConnection(dbconnection))
{
try
{
{
conn.Open();
using (SqlCommand cmd = new SqlCommand(@"
INSERT INTO Machine
(
MMId,MMName,MMPrice,MMGymName,MMPayment,
MMPayStatus,MMDelDate,MMDelAddress,MMDelStatus
)
VALUES
(
@mid,@mname,@mprice,@mgname,@mpayment,
@mpaymentstatus,@mdeliverydate,@mdeliveryaddress,
@mdeliverystatus
)", conn))
{
cmd.Parameters.AddWithValue("@mid", textmid.Text);
cmd.Parameters.AddWithValue("@mname", ComboBox1.Text);
cmd.Parameters.AddWithValue("@mprice", textmprice.Text);
cmd.Parameters.AddWithValue("@mgname", textmgymname.Text);
cmd.Parameters.AddWithValue("@mpayment", textmpayment.Text);
cmd.Parameters.AddWithValue("@mpaymentstatus", ps);
cmd.Parameters.AddWithValue("@mdeliverydate", textmdate.Text);
cmd.Parameters.AddWithValue("@mdeliveryaddress", textmdeladd.Text);
cmd.Parameters.AddWithValue("@mdeliverystatus", ds);
int rows = cmd.ExecuteNonQuery();
errormessage.Text = "You have Registered successfully.";
Reset();
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
finally
{
conn.Close();
}
}
}
private void RadioButton_Checked9(object sender, RoutedEventArgs e)
{
ps = "Advance";
}
private void RadioButton_Checked_6(object sender, RoutedEventArgs e)
{
ps = "Balance";
}
private void RadioButton_Checked_8(object sender, RoutedEventArgs e)
{
ps = "Full";
}
private void RadioButton_Checked(object sender, RoutedEventArgs e)
{
ds = "Yes";
}
private void RadioButton_Checked_1(object sender, RoutedEventArgs e)
{
ds = "No";
}
private void Status_Click(object sender, RoutedEventArgs e)
{
machinerecord mr = new machinerecord();
this.Close();
mr.ShowDialog();
}
private void RichTextBox_TextChanged_1(object sender, TextChangedEventArgs e)
{
}
public void Reset()
{
textmid.Text = "";
ComboBox1.Text = "";
textmdate.Text = "";
textmgymname.Text = "";
textmprice.Text = "";
textmdeladd.Text = "";
textmdate.Text = "";
textmpayment.Text = "";
}
private void ComboBox1_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
}
}