예제 #1
0
        private void dg_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            int       i  = dg.SelectedIndex;
            DataTable dt = E.fetch_data();

            if (dt.Rows.Count == 0)
            {
            }
            else
            {
                if (i >= 0)
                {
                    Save.Content       = "Update";
                    txtenquiryno.Text  = dt.Rows[i]["Enquiry_id"].ToString();
                    txtname.Text       = dt.Rows[i]["Name"].ToString();
                    txtcontact.Text    = dt.Rows[i]["Contact"].ToString();
                    txtcomingfrom.Text = dt.Rows[i]["ComingFrom"].ToString();
                    txtpax.Text        = dt.Rows[i]["Expected_Pax"].ToString();
                    txtrooms.Text      = dt.Rows[i]["Expected_Rooms"].ToString();
                    txtdate.Text       = Convert.ToDateTime(dt.Rows[i]["Expected_Arrival_Date"]).ToString();
                    txttime.Text       = dt.Rows[i]["TIME"].ToString();
                    cbroomtype.Text    = dt.Rows[i]["RoomType"].ToString();
                }
                else
                {
                }
            }
        }
예제 #2
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     if (error != 0 || txtname.Text == "" || txtcontact.Text == "" || txtpax.Text == "" || txtdate.Text == "" || txttime.Text == "" || txtrooms.Text == "")
     {
         txtdate.Text = "";
         //pop1.IsOpen = true;
         if (txtname.Text == "")
         {
             txtname.Text = "";
         }
         if (txtcontact.Text == "")
         {
             txtcontact.Text = "";
         }
         if (txtrooms.Text == "")
         {
             txtrooms.Text = "";
         }
         if (txtpax.Text == "")
         {
             txtpax.Text = "";
         }
         if (txtdate.Text == "")
         {
             txtdate.Text = string.Empty;
             txtdate.Text = null;
         }
         if (txttime.Text == "")
         {
             txttime.Text = "";
         }
     }
     else
     {
         Enquiry1 EN = new Enquiry1();
         //string a= txtdate.Text;
         EN.Enquiry_id            = Convert.ToInt32(txtenquiryno.Text);
         EN.Name                  = txtname.Text;
         EN.Contact               = Convert.ToInt64(txtcontact.Text);
         EN.ComingFrom            = txtcomingfrom.Text;
         EN.RoomType              = cbroomtype.Text;
         EN.Expected_Rooms        = Convert.ToInt32(txtrooms.Text);
         EN.Expected_Pax          = Convert.ToInt32(txtpax.Text);
         EN.Expected_Arrival_Date = Convert.ToDateTime(txtdate.Text);
         EN.Time                  = txttime.Text;
         EN.Insert_by             = login.u;
         EN.Insert_date           = DateTime.Today;
         string a = "Save"; string b = Convert.ToString(Save.Content);
         if (a == b)
         {
             EN.insert();
             DataTable dt = EN.fill_enquirygrid();
             dg.ItemsSource = dt.DefaultView;
             //MessageBox.Show("Saved sucessfully");
             popup_insert.IsOpen = true;
             clear();
         }
         else
         {
             EN.UPDATE();
             DataTable dt = EN.fetch_data();
             dg.ItemsSource = dt.DefaultView;
             //MessageBox.Show("Updated sucessfully");
             popup_update.IsOpen = true;
             clear();
             Save.Content = "Save";
         }
     }
 }