示例#1
0
        private void Add_Click(object sender, RoutedEventArgs e)
        {
            string name     = txtnewname.Text;
            string nic      = txtnewnic.Text;
            string address  = txtnewaddress.Text;
            int    tpNo     = Convert.ToInt32(txtnewphone.Text);
            string sellDate = sellingDate.SelectedDate.Value.ToString("yyyy-MM-dd");
            string vehicNo  = cmbReg.SelectedValue.ToString();

            try
            {
                SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["DBconnect"].ConnectionString);
                con.Open();
                SqlCommand cmd = new SqlCommand("update owner set sellDate='" + sellDate + "', nextName='" + name + "',nextAddress='" + address + "',nextNic='" + nic + "',nextTpno='" + tpNo + "' where vehicleNo='" + vehicNo + "' ", con);
                cmd.CommandType = CommandType.Text;
                cmd.ExecuteNonQuery();
                con.Close();

                alert alert = new alert("Added Successfully");
                alert.ShowDialog();
                clearDetails();
            }
            catch (Exception ex)
            {
                alert alert = new alert("Adding Failed");
                alert.ShowDialog();
            }
        }
示例#2
0
        public void UserLogin()
        {
            user = username.Text;
            pass = password.Password;
            SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["DBconnect"].ConnectionString);

            con.Open();
            SqlCommand cmd = new SqlCommand("select * from [dbo].[user] where username='******' and password= '******' and actdate <='" + today + "' ", con);

            cmd.CommandType = CommandType.Text;
            SqlDataAdapter adapter = new SqlDataAdapter();

            adapter.SelectCommand = cmd;
            DataSet dataSet = new DataSet();

            adapter.Fill(dataSet);
            if (dataSet.Tables[0].Rows.Count > 0)
            {
                homeAdmin home = new homeAdmin();
                this.Close();
                home.ShowDialog();
            }
            else
            {
                alert alert = new alert("Login Failed");
                alert.ShowDialog();
            }
            con.Close();
        }
示例#3
0
        private void add_Click(object sender, RoutedEventArgs e)
        {
            if (cmbvehiNo.Text == "" || txtdesc.Text == "" || txtvalue.Text == "")
            {
                alert alert = new alert("Fill all the details");
                alert.ShowDialog();
            }
            else
            {
                string  vehicleNo = cmbvehiNo.Text;
                string  desc      = txtdesc.Text;
                decimal value     = Math.Round(Convert.ToDecimal(txtvalue.Text), 2);
                string  date      = dpDate.SelectedDate.Value.ToString("yyyy-MM-dd");
                try
                {
                    con.Open();
                    SqlCommand cmd = new SqlCommand("INSERT INTO [dbo].[cost] ([vehicleNo],[date],[costType],[costPrice]) VALUES ('" + vehicleNo + "','" + date + "','" + desc + "','" + value + "')", con);
                    cmd.CommandType = CommandType.Text;
                    cmd.ExecuteNonQuery();
                    con.Close();
                    loadDetailsGrid();

                    txtdesc.Text  = "";
                    txtvalue.Text = "";
                    dpDate.Text   = DateTime.Now.ToString("dd/MM/yyyy");
                }

                catch (Exception ex)
                {
                    alert alert = new alert("Adding Failed");
                    alert.ShowDialog();
                }
            }
        }
示例#4
0
        private void AddBrand_Click(object sender, RoutedEventArgs e)
        {
            if (cmbType.Text == "" || txtBrand.Text == string.Empty)
            {
                alert alert1 = new alert("Both Type and Brand are required!");
                alert1.ShowDialog();
            }
            else
            {
                ComboBoxItem item = (ComboBoxItem)cmbType.SelectedItem;
                type = item.Content.ToString();

                con.Open();
                SqlCommand cmd = new SqlCommand("select MAX(brandKey) from brandComboLoad", con);
                cmd.CommandType = CommandType.Text;
                using (SqlDataReader reader = cmd.ExecuteReader())
                {
                    if (reader.Read())
                    {
                        oldBrandKey = Convert.ToInt32(reader[0]);
                        NewBrandKey = oldBrandKey + 1;
                    }
                }

                string newBrand = txtBrand.Text;

                SqlCommand cmd1 = new SqlCommand("INSERT INTO [dbo].[brandComboLoad] ([parentKey],[brandKey],[name],[type]) VALUES ('0','" + NewBrandKey + "','" + newBrand + "','" + type + "')", con);
                cmd1.CommandType = CommandType.Text;
                cmd1.ExecuteNonQuery();
                con.Close();

                alert alert = new alert("Added Successfully");
                alert.ShowDialog();
                txtBrand.Text = "";
            }
        }
示例#5
0
        private void AddName_Click(object sender, RoutedEventArgs e)
        {
            if (cmbType.Text == "" || cmbBrand.Text == "" || txtName.Text == string.Empty)
            {
                alert alert1 = new alert("Type, Brand and Name are Required! ");
                alert1.ShowDialog();
            }
            else
            {
                brand = cmbBrand.Text;

                ComboBoxItem item1 = (ComboBoxItem)cmbType.SelectedItem;
                type = item1.Content.ToString();

                con.Open();
                SqlCommand cmd = new SqlCommand("select brandKey from brandComboLoad where name='" + brand + "' and parentKey=0 and type='" + type + "'", con);
                cmd.CommandType = CommandType.Text;
                using (SqlDataReader reader = cmd.ExecuteReader())
                {
                    if (reader.Read())
                    {
                        parentKey = Convert.ToInt32(reader[0]);
                    }
                }
                string name = txtName.Text;

                SqlCommand cmd1 = new SqlCommand("INSERT INTO [dbo].[brandComboLoad] ([parentKey],[brandKey],[name],[type]) VALUES ('" + parentKey + "','0','" + name + "','" + type + "')", con);
                cmd1.CommandType = CommandType.Text;
                cmd1.ExecuteNonQuery();
                con.Close();

                alert alert = new alert("Added Successfully");
                alert.ShowDialog();
                txtName.Text = "";
            }
        }
示例#6
0
        private void save_click(object sender, RoutedEventArgs e)
        {
            if (txtvehiNo.Text == "" || txtengNo.Text == "" || txtchassiNo.Text == "" || cmbType.Text == "" || cmbBrand.Text == "" || cmbName.Text == "" || txtiniprice.Text == "" || txtremarks.Text == "" || dpInsuranceDate.Text == "" || dpRevenueDate.Text == "" || txtfullname.Text == "" || txtnic.Text == "" || txttpNo.Text == "" || dpDate.Text == "" || txtaddress.Text == "")
            {
                alert alert = new alert("Fill all the details!");
                alert.ShowDialog();
            }
            else
            {
                string vehicleNo = txtvehiNo.Text;
                string engNo     = txtengNo.Text;
                string chassiNo  = txtchassiNo.Text;
                string type      = cmbType.Text;
                string brand     = cmbBrand.Text;
                string name      = cmbName.Text;
                float  price     = (float)Convert.ToDouble(txtiniprice.Text);
                string remarks   = txtremarks.Text;

                //string revenueDateOld = dpRevenueDate.SelectedDate.ToString();
                //string[] Rdate = revenueDateOld.Split(' ');
                //string revenueDate = Rdate[0];
                string revenueDate = dpRevenueDate.SelectedDate.Value.ToString("yyyy-MM-dd");
                //DateTime.ParseExact(dpRevenueDate.Text, "yyyy/MM/dd", CultureInfo.CreateSpecificCulture("en-UK"));

                //string insuranceDateOld = dpInsuranceDate.SelectedDate.ToString();
                //string[] Idate = insuranceDateOld.Split(' ');
                //string insuranceDate = Idate[0];
                string insuranceDate = dpInsuranceDate.SelectedDate.Value.ToString("yyyy-MM-dd");
                //DateTime.ParseExact(dpInsuranceDate.Text, "yyyy/MM/dd", CultureInfo.CreateSpecificCulture("en-UK"));


                string fullname = txtfullname.Text;
                string nic      = txtnic.Text;
                int    tpNo     = Convert.ToInt32(txttpNo.Text);
                //string dateOld = dpDate.SelectedDate.ToString();
                // string[] Ddate = dateOld.Split(' ');
                // string date = Ddate[0];
                string date = dpDate.SelectedDate.Value.ToString("yyyy-MM-dd");
                //DateTime.ParseExact(dpDate.Text, "yyyy/MM/dd", CultureInfo.CreateSpecificCulture("en-UK"));

                string testDate = "";

                string address = txtaddress.Text;

                try
                {
                    SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["DBconnect"].ConnectionString);
                    con.Open();
                    SqlCommand cmd = new SqlCommand("INSERT INTO [dbo].[vehicle] ([vehicleNo],[engineNo],[chassiNo],[type],[brand],[name],[initialPrice],[insuranceDate],[revenueDate]) VALUES ('" + vehicleNo + "','" + engNo + "','" + chassiNo + "','" + type + "','" + brand + "','" + name + "', '" + price + "', '" + insuranceDate + "', '" + revenueDate + "') ", con);
                    cmd.CommandType = CommandType.Text;
                    cmd.ExecuteNonQuery();

                    SqlCommand cmd1 = new SqlCommand("INSERT INTO [dbo].[owner] ([vehicleNo],[preName],[preAddress],[preNic],[preTpno],[buyDate],[sellDate],[nextName] ,[nextAddress],[nextNic] ,[nextTpno]) VALUES ('" + vehicleNo + "','" + fullname + "','" + address + "','" + nic + "','" + tpNo + "','" + date + "','" + testDate + "','null','null','null',0)", con);
                    cmd1.CommandType = CommandType.Text;
                    cmd1.ExecuteNonQuery();
                    con.Close();

                    alert alert = new alert("Added Successfully");
                    alert.ShowDialog();
                    clearFields();
                }
                catch (Exception ex)
                {
                    alert alert = new alert("Adding Failed");
                    alert.ShowDialog();
                }
            }
        }