using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Configuration;
using System.Data.SqlClient;
namespace AyuBo_Pvt
{
public partial class Rent : Form
{
public Rent()
{
InitializeComponent();
}
SqlConnection con = new SqlConnection(@"Data Source=DESKTOP-PJOEEF0\MSSQLSERVER01;Initial Catalog=Ayubo;Integrated Security=True");
private void populate()
{
con.Open();
string query = "Select * from Vehicle_details";
SqlDataAdapter dp = new SqlDataAdapter(query, con);
SqlCommandBuilder builder = new SqlCommandBuilder(dp);
var ds = new DataSet();
dp.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];
con.Close();
}
private void button1_Click(object sender, EventArgs e)
{
DateTime date1 = dateTimePicker1.Value.Date;
DateTime date2 = dateTimePicker2.Value.Date;
int dateiff = ((TimeSpan)(date2 - date1)).Days;
textBox8.Text = dateiff.ToString();
int months, weeks, days, remainder;
int gap = Convert.ToInt32(textBox8.Text);
months = gap / 30;
remainder = gap % 30;
weeks = remainder / 7;
days = remainder % 7;
textBox7.Text = days.ToString();
textBox4.Text = weeks.ToString();
textBox6.Text = months.ToString();
}
private void btnUpdate_Click(object sender, EventArgs e)
{
}
private void label8_Click(object sender, EventArgs e)
{
}
private void Rent_Load(object sender, EventArgs e)
{
populate();
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
int index = e.RowIndex;
DataGridViewRow SelectedRow = dataGridView1.Rows[index];
textBox3.Text = SelectedRow.Cells[0].Value.ToString();
textBox12.Text = SelectedRow.Cells[1].Value.ToString();
textBox9.Text = SelectedRow.Cells[2].Value.ToString();
textBox11.Text = SelectedRow.Cells[3].Value.ToString();
textBox2.Text = SelectedRow.Cells[4].Value.ToString();
textBox1.Text = SelectedRow.Cells[5].Value.ToString();
textBox10.Text = SelectedRow.Cells[6].Value.ToString();
textBox5.Text = SelectedRow.Cells[7].Value.ToString();
}
private void button3_Click(object sender, EventArgs e)
{
int day = Convert.ToInt32(textBox7.Text);
int daily = Convert.ToInt32(textBox9.Text);
int week = Convert.ToInt32(textBox4.Text);
int weekly = Convert.ToInt32(textBox11.Text);
int month = Convert.ToInt32(textBox6.Text);
int monthly = Convert.ToInt32(textBox10.Text);
int nbDays = Convert.ToInt32(textBox8.Text);
int driverRate = Convert.ToInt32(textBox5.Text);
label12.Text = Convert.ToString((day * daily) + (week * weekly) + (month * monthly) + (nbDays * driverRate));
label13.Text = Convert.ToString((day * daily) + (week * weekly) + (month * monthly));
}
private void textBox13_TextChanged(object sender, EventArgs e)
{
}
private void btnHome_Click(object sender, EventArgs e)
{
Home_Page hp = new Home_Page();
hp.Show();
this.Hide();
}
private void btnExit_Click(object sender, EventArgs e)
{
Application.Exit();
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Configuration;
using System.Data.SqlClient;
namespace AyuBo_Pvt
{
public partial class Rent : Form
{
public Rent()
{
InitializeComponent();
}
SqlConnection con = new SqlConnection(@"Data Source=DESKTOP-PJOEEF0\MSSQLSERVER01;Initial Catalog=Ayubo;Integrated Security=True");
private void populate()
{
con.Open();
string query = "Select * from Vehicle_details";
SqlDataAdapter dp = new SqlDataAdapter(query, con);
SqlCommandBuilder builder = new SqlCommandBuilder(dp);
var ds = new DataSet();
dp.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];
con.Close();
}
private void button1_Click(object sender, EventArgs e)
{
DateTime date1 = dateTimePicker1.Value.Date;
DateTime date2 = dateTimePicker2.Value.Date;
int dateiff = ((TimeSpan)(date2 - date1)).Days;
textBox8.Text = dateiff.ToString();
int months, weeks, days, remainder;
int gap = Convert.ToInt32(textBox8.Text);
months = gap / 30;
remainder = gap % 30;
weeks = remainder / 7;
days = remainder % 7;
textBox7.Text = days.ToString();
textBox4.Text = weeks.ToString();
textBox6.Text = months.ToString();
}
private void btnUpdate_Click(object sender, EventArgs e)
{
}
private void label8_Click(object sender, EventArgs e)
{
}
private void Rent_Load(object sender, EventArgs e)
{
populate();
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
int index = e.RowIndex;
DataGridViewRow SelectedRow = dataGridView1.Rows[index];
textBox3.Text = SelectedRow.Cells[0].Value.ToString();
textBox12.Text = SelectedRow.Cells[1].Value.ToString();
textBox9.Text = SelectedRow.Cells[2].Value.ToString();
textBox11.Text = SelectedRow.Cells[3].Value.ToString();
textBox2.Text = SelectedRow.Cells[4].Value.ToString();
textBox1.Text = SelectedRow.Cells[5].Value.ToString();
textBox10.Text = SelectedRow.Cells[6].Value.ToString();
textBox5.Text = SelectedRow.Cells[7].Value.ToString();
}
private void button3_Click(object sender, EventArgs e)
{
int day = Convert.ToInt32(textBox7.Text);
int daily = Convert.ToInt32(textBox9.Text);
int week = Convert.ToInt32(textBox4.Text);
int weekly = Convert.ToInt32(textBox11.Text);
int month = Convert.ToInt32(textBox6.Text);
int monthly = Convert.ToInt32(textBox10.Text);
int nbDays = Convert.ToInt32(textBox8.Text);
int driverRate = Convert.ToInt32(textBox5.Text);
label12.Text = Convert.ToString((day * daily) + (week * weekly) + (month * monthly) + (nbDays * driverRate));
label13.Text = Convert.ToString((day * daily) + (week * weekly) + (month * monthly));
}
private void textBox13_TextChanged(object sender, EventArgs e)
{
}
private void btnHome_Click(object sender, EventArgs e)
{
Home_Page hp = new Home_Page();
hp.Show();
this.Hide();
}
private void btnExit_Click(object sender, EventArgs e)
{
Application.Exit();
}
}
}