예제 #1
0
 private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (!comboBox1.SelectedItem.ToString().Equals("Select Vehicle"))
     {
         label3.Text = db.GetValue("SELECT[Status]FROM [AVVMS].[dbo].[Vehicles] where [Vehicle No.]='" + comboBox1.SelectedItem.ToString() + "'");
         label3.Show();
     }
 }
예제 #2
0
        public Lisence_Renew_Input()
        {
            InitializeComponent();
            label2.Text = (Convert.ToInt32(db.GetValue("SELECT [no] FROM [AVVMS].[dbo].[license renew]")) + 1).ToString();
            DataTable dt = new DataTable();

            dt = db.GetTable("SELECT [Employee ID]FROM [AVVMS].[dbo].[Employee] where Status != 'Removed' AND Category='Driver'");

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                comboBox1.Items.Add(dt.Rows[i]["Employee ID"].ToString());
            }
            comboBox1.SelectedIndex = 0;
            label11.Hide();
        }
    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {
        id = Convert.ToInt32(GridView1.SelectedRow.Cells[1].Text);
        string path = db.GetValue("select sd_path from studymaterials where sd_id=" + id);
        string p    = Server.MapPath(path);
        string n    = System.IO.Path.GetFileName(p);

        //Label1.Text = path;
        //string n2 = System.IO.Path.GetExtension(p);
        Response.Redirect("http://localhost/cyber_tution/study/" + n);
        // Page pa = HttpContext.Current.CurrentHandler as Page;
        // pa.ClientScript.RegisterStartupScript(typeof(Page), "Error", "<script language=\"JavaScript\" type=\"text/javascript\">window.location.replace("+path+");</script>");
        // Response.Redirect(p);
        //System.IO.File.Open(p, System.IO.FileMode.Open);
        //string name=@"
        //Response.ContentType = "appliction/octet-stream";

        /* Response.ContentType = n2;
         * Response.AppendHeader("Content-Disposition","attachment;filename="+n);
         * System.Threading.Thread.Sleep(100);
         * Response.TransmitFile(p);
         * Response.End();*/
        //System.Diagnostics.Process.Start(path);
        //Labelerror.Text = id.ToString();
        //DataTable dt1 = dh.GetTable("Select * from subjects where sub_id= " + id);

        //txt_sub.Text = dt1.Rows[0][1].ToString();
        //txt_syll.Text = dt1.Rows[0][2].ToString();
        //txt_fee.Text = dt1.Rows[0][3].ToString();
        //Button2.Visible = false;
        //Button1.Visible = true;
    }
예제 #4
0
 protected void Button3_Click(object sender, EventArgs e)
 {
     try
     {
         //int c = 0;
         String count = DH.GetValue("SELECT        MAX(qstn_no) FROM            examdetails ");
         if (count.Equals(null))
         {
             c = 1;
         }
         else
         {
             c++;
         }
         DH.Ins_Up_Del("insert into ExamDetails values(" + DropDownList1.SelectedValue.ToString() + "," + c + ",'" + txt_qstion.Text + "','" + txt_1.Text + "','" + txt_2.Text + "','" + txt_3.Text + "','" + txt_4.Text + "','" + dropdwn_ans.SelectedValue.ToString() + "')");
         Labelerror.Text = "Saved Successfully !";
         FillTable();
         ClearAll();
         MultiView1.ActiveViewIndex = 1;
     }
     catch (Exception ex)
     {
         Labelerror.Text = "Error in Saving!";
     }
 }
예제 #5
0
    protected void Button1_Click1(object sender, EventArgs e)
    {
        if (FileUpload1.PostedFile != null)
        {
            //string fileExt =
            //   System.IO.Path.GetExtension(FileUpload1.FileName);

            //if (fileExt == ".jpeg" || fileExt == ".jpg")
            //{

            // Get the HttpFileCollection


            try
            {
                Labelerror.Text = "";
                HttpFileCollection hfc = Request.Files;
                for (int i = 0; i < hfc.Count; i++)
                {
                    HttpPostedFile hpf = hfc[i];
                    // if (hpf.ContentLength > 0 && (hpf.FileName.Contains(".jpeg") || hpf.FileName.Contains(".jpg")))
                    if (hpf.ContentLength > 0)
                    {
                        //if (hpf.FileName.ToString().Contains(".wmv"))
                        //{
                        //int c;
                        String count = dh.GetValue("SELECT        MAX(sd_id) FROM            tution ");
                        if (count.Equals(null))
                        {
                            c = 1;
                        }
                        else
                        {
                            c++;
                        }
                        hpf.SaveAs(Server.MapPath("Study") + "\\" + System.IO.Path.GetFileName(hpf.FileName));
                        dh.Ins_Up_Del("INSERT INTO tution                         (sd_id, sub_id, sd_chapter, sd_path, ImageName, Description)VALUES    (" + c + "," + DropDownList1.SelectedValue.ToString() + ",1,'" + "Study\\" + System.IO.Path.GetFileName(hpf.FileName) + "','" + hpf.FileName.ToString() + "','')");
                        Labelerror.Text = Labelerror.Text.ToString() + "<b>File: </b>" + hpf.FileName + " <b>Size:</b> " +
                                          hpf.ContentLength + " <b>Type:</b> " + hpf.ContentType + " Uploaded Successfully <br/>";
                        //  }
                        //{
                        //  Labelerror.Text = "choose wmv file";
                        //}
                    }
                }
            }

            catch (Exception ex)
            {
                Labelerror.Text = "Error on Uploading!";
            }
            //  }
        }
    }
 protected void txt_uname_TextChanged(object sender, EventArgs e)
 {
     if (txt_uname.Text != string.Empty)
     {
         string cnt = dh.GetValue("select count(*) from student where stud_uname='" + txt_uname.Text + "'");
         if (cnt != "0")
         {
             imgUser.ImageUrl  = "~/images/unavailable.png";
             imgUser.Visible   = true;
             lblUser.Text      = "Unavailable";
             lblUser.ForeColor = System.Drawing.Color.Red;
         }
         else
         {
             imgUser.ImageUrl  = "~/images/tick.png";
             imgUser.Visible   = true;
             lblUser.Text      = "Available";
             lblUser.ForeColor = System.Drawing.Color.Yellow;
         }
     }
 }
예제 #7
0
        public Batha_Assign()
        {
            InitializeComponent();
            dt = db.GetTable("SELECT [Light half Batha] ,[light full batha] ,[light extra amount] ,[light hault batha] ,[heavy half batha] ,[heavy hault batha] ,[heavy full batha] ,[heavy km alavence driver] ,[heavy km alavence permanent cleaner] ,[heavy km alavance temporary cleaner] ,[heavy extra amount driver] ,[heavy extra amount cleaner]FROM [AVVMS].[dbo].[batha]");
            light_half.Text  = dt.Rows[0]["Light half Batha"].ToString();
            light_full.Text  = dt.Rows[0]["light full batha"].ToString();
            light_extra.Text = dt.Rows[0]["light extra amount"].ToString();
            light_hault.Text = dt.Rows[0]["light hault batha"].ToString();
            heavy_half.Text  = dt.Rows[0]["heavy half batha"].ToString();
            heavy_full.Text  = dt.Rows[0]["heavy full batha"].ToString();
            heavy_hault.Text = dt.Rows[0]["heavy hault batha"].ToString();
            heavykm_d.Text   = dt.Rows[0]["heavy km alavence driver"].ToString();
            heavykm_p.Text   = dt.Rows[0]["heavy km alavence permanent cleaner"].ToString();
            heavykm_t.Text   = dt.Rows[0]["heavy km alavance temporary cleaner"].ToString();
            heavyed.Text     = dt.Rows[0]["heavy extra amount driver"].ToString();
            heavyec.Text     = dt.Rows[0]["heavy extra amount cleaner"].ToString();

            tgm.Text  = db.GetValue("SELECT [gm] FROM [AVVMS].[dbo].[exceptional_trip]");
            tjgm.Text = db.GetValue("SELECT [jgm] FROM [AVVMS].[dbo].[exceptional_trip]");
            tspe.Text = db.GetValue("SELECT [special] FROM [AVVMS].[dbo].[exceptional_trip]");
        }
    protected void Button2_Click(object sender, EventArgs e)
    {
        string cnt = dh.GetValue("select count(*) from examdetails where exam_id=" + DropDownList1.SelectedValue.ToString());

        if (cnt != "0")
        {
            Labelerror.Text = "";
            Response.Redirect("TakeTest2.aspx?exam_id=" + DropDownList1.SelectedValue.ToString());
        }
        else
        {
            Labelerror.Text = "Question Paper Not prepared yet ";
        }
    }
예제 #9
0
        private void dataGridView6_Click(object sender, EventArgs e)
        {
            if (dataGridView6.SelectedRows.Count != 0)
            {
                groupBox1.Text = "Trip No. : " + dataGridView6.SelectedRows[0].Cells[0].Value.ToString();


                if (db.GetValue("SELECT [Type]FROM [AVVMS].[dbo].[Vehicles] where [Vehicle No.]='" + dataGridView6.SelectedRows[0].Cells[1].Value.ToString() + "'").Contains("Heavy"))
                {
                    dt = db.GetTable("SELECT [first cleaner],[second cleaner],[address],[start meter],[start time],[moment slip no.]FROM [AVVMS].[dbo].[Trips] where [id]=" + dataGridView6.SelectedRows[0].Cells[0].Value.ToString() + "");

                    lb_fc.Text = "First Cleaner : " + dt.Rows[0]["first cleaner"].ToString();
                    if (dt.Rows[0]["second cleaner"].ToString().Equals(""))
                    {
                        Common_Tasks.nullify(lb_sc);
                    }
                    else
                    {
                        lb_sc.Text = "Second Cleaner : " + dt.Rows[0]["second cleaner"].ToString();
                    }
                }
                else
                {
                    Common_Tasks.nullify(lb_fc);
                    Common_Tasks.nullify(lb_sc);
                    dt = db.GetTable("SELECT [address],[start meter],[start time],[moment slip no.]FROM [AVVMS].[dbo].[Trips] where [id]=" + dataGridView6.SelectedRows[0].Cells[0].Value.ToString() + "");
                }

                lb_address.Text    = "Provider Address : " + dt.Rows[0]["address"].ToString();
                lb_startmeter.Text = "Start Meter : " + dt.Rows[0]["start meter"].ToString();
                lb_starttime.Text  = "Start Time : " + dt.Rows[0]["start time"].ToString();
                lb_moment.Text     = "Moment Slip No. : " + dt.Rows[0]["moment slip no."].ToString();

                groupBox1.Show();
            }
        }
예제 #10
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["user_id"] == null)
        {
            Response.Write("<script>alert('Your Session Timer has Expired! We are Sorry!')</script>");
            Response.Redirect("StudentHome.aspx");
        }

        if (!IsPostBack)
        {
            this.timerStartValue = 60000;//long.Parse(ConfigurationManager.AppSettings["Delay"].ToString());
            this.TimerInterval   = 500;
            tno = Request.QueryString["exam_id"].ToString();

            Questions = GetDataSet();

            totalQs = Convert.ToInt32(dh.GetValue("select count(*) from ExamDetails where exam_id=" + tno + ""));
            LoadQuestion();

            DataSet questions = new DataSet("Questions");
            questions.Tables.Add();
            marks = 0;
        }
    }
예제 #11
0
 private void comboBox4_SelectedIndexChanged(object sender, EventArgs e)
 {
     label5.Text = db.GetValue("SELECT [Meter Reading]FROM [AVVMS].[dbo].[Vehicles] where [Vehicle No.]='" + combovehi.SelectedItem.ToString() + "'");
 }
예제 #12
0
    protected void CreateUserButton_Click(object sender, EventArgs e)
    {
        Label6.Visible = false;
        if (TextBox5.Text.Length > 20)
        {
            Label6.CssClass = "failurenotification";
            Label6.Text     = "Maximum length is 20";
            Label6.Visible  = true;
        }
        else
        {
            if (TextBox5.Text.Length < 6)
            {
                Label6.CssClass = "failurenotification";
                Label6.Text     = "Minimum length is 6";
                Label6.Visible  = true;
            }
            else
            {
                Label1.Visible = false;
                if ((TextBox1.Text.Length > 12) || (TextBox1.Text.Length < 6))
                {
                    Label1.CssClass = "failurenotification";
                    Label1.Visible  = true;
                }
                else
                {
                    DataTable dt = dh.GetTable("select uid from login where username='******'");

                    if (dt.Rows.Count > 0)
                    {
                        Label1.CssClass = "failurenotification";
                        Label1.Text     = "Username is already taken,Please choose another one";
                        Label1.Visible  = true;
                    }
                    else
                    {
                        Label2.Visible = false;
                        if (string.IsNullOrEmpty(TextBox2.Text))
                        {
                            Label2.CssClass = "failurenotification";
                            Label2.Visible  = true;
                        }
                        else
                        {
                            dt.Clear();
                            dt = dh.GetTable("select uid from [user] where (email='" + TextBox2.Text + "')");

                            if (dt.Rows.Count > 0)
                            {
                                Label2.CssClass = "failurenotification";
                                Label2.Text     = "Email is already used,Please choose another one";
                                Label2.Visible  = true;
                            }
                            else
                            {
                                Label3.Visible = false;
                                if ((TextBox3.Text.Length < 6) || (TextBox3.Text.Length > 16))
                                {
                                    Label3.CssClass = "failurenotification";
                                    Label3.Visible  = true;
                                }
                                else
                                {
                                    Label4.Visible = false;
                                    if (!TextBox3.Text.Equals(TextBox4.Text))
                                    {
                                        Label4.CssClass = "failurenotification";
                                        Label4.Text     = "The Password and Confirmation Password must match.";
                                        Label4.Visible  = true;
                                    }
                                    else
                                    {
                                        int uc = Convert.ToInt32(dh.GetValue("select uc from sdata"));
                                        uc++;
                                        string gen = DropDownListe0.SelectedItem.ToString();

                                        string genp = DropDownListp.SelectedItem.ToString();
                                        string gene = DropDownListe.SelectedItem.ToString();

                                        dh.Ins_Up_Del("insert into [user](uid,name,phone,email,place,gender,phones,emails)values(" + uc + ",'" + TextBox5.Text + "','" + TextBox6.Text + "','" + TextBox2.Text + "','" + TextBox7.Text + "','" + gen + "','" + genp + "','" + gene + "')");

                                        dh.Ins_Up_Del("insert into [login](uid,username,password,statusid)values(" + uc + ",'" + TextBox1.Text + "','" + TextBox3.Text + "','offline')");



                                        dh.Ins_Up_Del("update [sdata] set uc=" + uc);
                                        Response.Redirect("login.aspx");
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
예제 #13
0
        public Trip_Completion(string id, string vehicle, string purpose, string name, string address, string mobile, string driver, string startm, string startt, string sdate, string remark, string j, string fc, string sc)
        {
            InitializeComponent();


            dateTimePicker1.MinDate = DateTime.Parse(sdate);

            numericUpDown1.Minimum = ((Convert.ToInt32(startm)));


            DGV_traffic_exception.Rows.Add("Toll Fee", "", "");
            DGV_traffic_exception.Rows.Add("Parking Fee", "", "");
            DGV_traffic_exception.Rows.Add("Fuel", "", "");
            label20.Text    = id;
            lb_address.Text = address;
            lb_driver.Text  = driver;
            lb_mobile.Text  = mobile;
            lb_name.Text    = name;
            lb_purpose.Text = purpose;
            lb_smeter.Text  = startm;

            lb_vehicle.Text = vehicle;


            lb_remarks.Text = remark;
            ld_sdatea.Text  = sdate + " " + startt;
            date            = sdate;

            lb_j.Text  = j;
            lb_fc.Text = fc;
            lb_sc.Text = sc;


            label31.Text = db.GetValue("SELECT [mail]FROM [AVVMS].[dbo].[Trips] where [Id]='" + id + "'");
            tefc.Text    = db.GetValue("SELECT [heavy extra amount cleaner]FROM [AVVMS].[dbo].[batha]");

            if (db.GetValue("SELECT [Type]FROM [AVVMS].[dbo].[Employee] where [Employee ID]='" + fc + "'").Equals("Permanent"))
            {
                tkmfc.Text = db.GetValue("SELECT [heavy km alavence permanent cleaner]FROM [AVVMS].[dbo].[batha]");
            }
            else
            {
                tkmfc.Text = db.GetValue("SELECT [heavy km alavance temporary cleaner]FROM [AVVMS].[dbo].[batha]");
            }

            if (sc.Equals(""))
            {
                groupBox2.Text = groupBox2.Text + " : For Driver,First Cleaner";
                panel2sc.Hide();
                Common_Tasks.nullify(label4);

                jtype = 2;
            }
            else
            {
                groupBox2.Text = groupBox2.Text + " : For Driver,First Cleaner,Second Cleaner";
                jtype          = 3;

                tesc.Text = tefc.Text;
                if (db.GetValue("SELECT [Type]FROM [AVVMS].[dbo].[Employee] where [Employee ID]='" + sc + "'").Equals("Permanent"))
                {
                    tkmsc.Text = db.GetValue("SELECT [heavy km alavence permanent cleaner]FROM [AVVMS].[dbo].[batha]");
                }
                else
                {
                    tkmsc.Text = db.GetValue("SELECT [heavy km alavance temporary cleaner]FROM [AVVMS].[dbo].[batha]");
                }
            }


            lb_b.Hide();
            txt_hbatha.Hide();

            ebatha.Text    = db.GetValue("SELECT [heavy extra amount driver]FROM [AVVMS].[dbo].[batha]");
            hbatha.Text    = db.GetValue("SELECT [heavy hault batha]FROM [AVVMS].[dbo].[batha]");
            tkmdheavy.Text = db.GetValue("SELECT [heavy km alavence driver]FROM [AVVMS].[dbo].[batha]");

            ini_flag = 1;
        }
예제 #14
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (Validation())
            {
                db.Ins_Up_Del("INSERT INTO [AVVMS].[dbo].[refill bill]([date],[vehicle],[bunk],[amount],[remark],litres)VALUES('" + dateTimePicker1.Value.ToShortDateString() + "','" + comboBoxv.SelectedItem.ToString() + "'," + comboBoxbunk.SelectedItem.ToString() + "," + tam.Text + ",'" + tbill.Text + "'," + tpretr.Text + ")");

                db.Ins_Up_Del("UPDATE [AVVMS].[dbo].[Vehicles]SET [last refill date] = '" + dateTimePicker1.Value.ToShortDateString() + "' WHERE     ([Vehicle No.] = '" + comboBoxv.SelectedItem.ToString() + "')");

                db.Ins_Up_Del("UPDATE [AVVMS].[dbo].[pbunk]SET [amount] = " + ((Convert.ToDouble(tam.Text)) + (Convert.ToDouble(db.GetValue("SELECT [amount] FROM [AVVMS].[dbo].[pbunk] WHERE     ([no] = " + comboBoxbunk.SelectedItem.ToString() + ")")))) + " WHERE     ([no] = " + comboBoxbunk.SelectedItem.ToString() + ")");

                MessageBox.Show("Added");
                this.Close();
            }
        }
예제 #15
0
        private void button3_Click(object sender, EventArgs e)
        {
            if (Validation())
            {
                if (update_flag == 0)
                {
                    String message = "";
                    int    c1f     = 0;

                    for (int i = 0; i < dataGridView1.Rows.Count; i++)
                    {
                        if (dataGridView1.Rows[i].Cells[1].Value.ToString().Equals(""))
                        {
                            c1f = 1;
                            if (message.Equals(""))
                            {
                                message = message + "Enter Address For Supplier No. : " + (i + 1);
                            }
                            else
                            {
                                message = message + "\nEnter Address For Supplier No. : " + (i + 1);
                            }
                        }
                        if (dataGridView1.Rows[i].Cells[2].Value.ToString().Equals(""))
                        {
                            c1f = 1;
                            if (message.Equals(""))
                            {
                                message = message + "Enter Qoutation Amount For Supplier No. : " + (i + 1);
                            }
                            else
                            {
                                message = message + "\nEnter Qoutation Amount For Supplier No. : " + (i + 1);
                            }
                        }
                        else
                        {
                            try
                            {
                                Decimal k = Convert.ToDecimal(dataGridView1.Rows[i].Cells[2].Value.ToString());
                            }
                            catch (FormatException ex)
                            {
                                c1f = 1;
                                if (message.Equals(""))
                                {
                                    message = message + "Enter Correct Qoutation Amount For Supplier No. : " + (i + 1);
                                }
                                else
                                {
                                    message = message + "\nEnter Correct Qoutation Amount For Supplier No. : " + (i + 1);
                                }
                            }
                        }
                    }
                    for (int i = 0; i < DGV_traffic_exception.Rows.Count; i++)
                    {
                        if (DGV_traffic_exception.Rows[i].Cells[0].Value.ToString().Equals(""))
                        {
                            c1f = 1;
                            if (message.Equals(""))
                            {
                                message = message + "Enter Description For Traffic Exception No. : " + (i + 1);
                            }
                            else
                            {
                                message = message + "\nEnter Description For Traffic Exception No. : " + (i + 1);
                            }
                        }
                        if (DGV_traffic_exception.Rows[i].Cells[1].Value.ToString().Equals(""))
                        {
                            c1f = 1;
                            if (message.Equals(""))
                            {
                                message = message + "Enter Expiry Date For Traffic Exception No. : " + (i + 1);
                            }
                            else
                            {
                                message = message + "\nEnter Expiry Date For Traffic Exception No. : " + (i + 1);
                            }
                        }
                    }
                    if (c1f == 0)
                    {
                        try
                        {
                            for (int i = 0; i < dataGridView1.Rows.Count; i++)
                            {
                                db.Ins_Up_Del("INSERT INTO [AVVMS].[dbo].[qoutation]([supplier],[quotation amount],[vehicle no.]) VALUES ('" + dataGridView1.Rows[i].Cells[1].Value.ToString() + "'," + dataGridView1.Rows[i].Cells[2].Value.ToString() + " ,'" + tno.Text + "')");
                            }
                            String n = "";
                            if (DGV_traffic_exception.Rows.Count != 0)
                            {
                                for (int i = 0; i < DGV_traffic_exception.Rows.Count; i++)
                                {
                                    db.Ins_Up_Del("INSERT INTO [AVVMS].[dbo].[traffic exception]([traffic exception due],[expiry date],[vehicle no.]) VALUES ('" + DGV_traffic_exception.Rows[i].Cells[0].Value.ToString() + "','" + DGV_traffic_exception.Rows[i].Cells[1].Value.ToString() + "' ,'" + tno.Text + "')");

                                    if ((DateTime.Parse(DateTime.Now.ToShortDateString()).AddDays(15).CompareTo(DateTime.Parse(DGV_traffic_exception.Rows[i].Cells[1].Value.ToString()))) >= 0)
                                    {
                                        db.Ins_Up_Del("INSERT INTO [AVVMS].[dbo].[Vehicle_Notifications]([Vehicle],[Reason],[Remarks])VALUES('" + tno.Text + "','Traffic Exception Due Certificate-" + DGV_traffic_exception.Rows[i].Cells[0].Value.ToString() + " of Vehicle No. : " + tno.Text + " will expire On : " + DGV_traffic_exception.Rows[i].Cells[1].Value.ToString() + "','Expiration Date : " + DGV_traffic_exception.Rows[i].Cells[1].Value.ToString() + "')");
                                        if (n.Equals(""))
                                        {
                                            n = n + "Traffic Exception Due Certificate-" + DGV_traffic_exception.Rows[i].Cells[0].Value.ToString() + " of Vehicle No. : " + tno.Text + " will expire On : " + DGV_traffic_exception.Rows[i].Cells[1].Value.ToString() + "";
                                        }
                                        else
                                        {
                                            n = n + "\nTraffic Exception Due Certificate-" + DGV_traffic_exception.Rows[i].Cells[0].Value.ToString() + " of Vehicle No. : " + tno.Text + " will expire On : " + DGV_traffic_exception.Rows[i].Cells[1].Value.ToString() + "";
                                        }
                                    }
                                }
                            }

                            db.Ins_Up_Del("INSERT INTO [AVVMS].[dbo].[Vehicles]([Vehicle No.],[Type],[Model],[Fuel Capacity],[Fuel Refill Limit],[Meter Reading],[Engine No.],[Horse Power],[Chasis No.],[Fuel Type],[Color],[Engine CC],[Quotatio date],[Selected Quotation No.],[Purchase Amount],[Cheque No.],[Purchase date],[Tax Expiry date],[RC Expiry date],[Insurance Expiry date],[CF date],[Pollution Certificate Expiry date],[Permit Expiry date],[Green Tax Expiry date],[Status],[fuel],[Full tank],weight)VALUES('" + tno.Text + "','" + combotype.SelectedItem.ToString() + "','" + tmodel.Text + "'," + tmila.Text + "," + tfrefill.Text + "," + tmeter.Text + ",'" + teno.Text + "','" + thorse.Text + "','" + tchasis.Text + "','" + combofuel.Text + "','" + tcolor.Text + "','" + tecc.Text + "','" + dateTimePickerqdate.Value.ToShortDateString() + "','" + tsupplierno.Text + "','" + tpurchaseno.Text + "','" + tchequeno.Text + "','" + dateTimePickerpurchase.Value.ToShortDateString() + "','" + dateTimePickertax.Value.ToShortDateString() + "','" + dateTimePickerrc.Value.ToShortDateString() + "','" + dateTimePickerinsurance.Value.ToShortDateString() + "','" + dateTimePickercf.Value.ToShortDateString() + "','" + dateTimePickerpollution.Value.ToShortDateString() + "','" + dateTimePickerpermit.Value.ToShortDateString() + "','" + dateTimePickergreen.Value.ToShortDateString() + "','Available'," + tfcapacity.Text + "," + tfcapacity.Text + "," + tweight.Text + ")");

                            MessageBox.Show("Inserted Successfully");


                            String m = "";

                            if ((DateTime.Parse(DateTime.Now.ToShortDateString()).AddDays(15).CompareTo(DateTime.Parse(dateTimePickertax.Value.ToShortDateString()))) >= 0)
                            {
                                db.Ins_Up_Del("INSERT INTO [AVVMS].[dbo].[Vehicle_Notifications]([Vehicle],[Reason],[Remarks])VALUES('" + tno.Text + "','Tax Certificate of Vehicle No. : " + tno.Text + " will expire On : " + dateTimePickertax.Value.ToShortDateString() + "','Expiration Date : " + dateTimePickertax.Value.ToShortDateString() + "')");
                                if (m.Equals(""))
                                {
                                    m = m + "Tax Certificate of Vehicle No. : " + tno.Text + " will expire On : " + dateTimePickertax.Value.ToShortDateString() + "";
                                }
                                else
                                {
                                    m = m + "\nTax Certificate of Vehicle No. : " + tno.Text + " will expire On : " + dateTimePickertax.Value.ToShortDateString() + "";
                                }
                            }

                            if ((DateTime.Parse(DateTime.Now.ToShortDateString()).AddDays(15).CompareTo(DateTime.Parse(dateTimePickerrc.Value.ToShortDateString()))) >= 0)
                            {
                                db.Ins_Up_Del("INSERT INTO [AVVMS].[dbo].[Vehicle_Notifications]([Vehicle],[Reason],[Remarks])VALUES('" + tno.Text + "','RC of Vehicle No. : " + tno.Text + " will expire On : " + dateTimePickerrc.Value.ToShortDateString() + "','Expiration Date : " + dateTimePickerrc.Value.ToShortDateString() + "')");

                                if (m.Equals(""))
                                {
                                    m = m + "RC of Vehicle No. : " + tno.Text + " will expire On : " + dateTimePickerrc.Value.ToShortDateString() + "";
                                }
                                else
                                {
                                    m = m + "\nRC of Vehicle No. : " + tno.Text + " will expire On : " + dateTimePickerrc.Value.ToShortDateString() + "";
                                }
                            }

                            if ((DateTime.Parse(DateTime.Now.ToShortDateString()).AddDays(15).CompareTo(DateTime.Parse(dateTimePickerinsurance.Value.ToShortDateString()))) >= 0)
                            {
                                db.Ins_Up_Del("INSERT INTO [AVVMS].[dbo].[Vehicle_Notifications]([Vehicle],[Reason],[Remarks])VALUES('" + tno.Text + "','Insurance of Vehicle No. : " + tno.Text + " will expire On : " + dateTimePickerinsurance.Value.ToShortDateString() + "','Expiration Date : " + dateTimePickerinsurance.Value.ToShortDateString() + "')");

                                if (m.Equals(""))
                                {
                                    m = m + "Insurance of Vehicle No. : " + tno.Text + " will expire On : " + dateTimePickerinsurance.Value.ToShortDateString() + "";
                                }
                                else
                                {
                                    m = m + "\nInsurance of Vehicle No. : " + tno.Text + " will expire On : " + dateTimePickerinsurance.Value.ToShortDateString() + "";
                                }
                            }

                            if ((DateTime.Parse(DateTime.Now.ToShortDateString()).AddDays(15).CompareTo(DateTime.Parse(dateTimePickercf.Value.ToShortDateString()))) >= 0)
                            {
                                db.Ins_Up_Del("INSERT INTO [AVVMS].[dbo].[Vehicle_Notifications]([Vehicle],[Reason],[Remarks])VALUES('" + tno.Text + "','CF of Vehicle No. : " + tno.Text + " will expire On : " + dateTimePickercf.Value.ToShortDateString() + "','Expiration Date : " + dateTimePickercf.Value.ToShortDateString() + "')");

                                if (m.Equals(""))
                                {
                                    m = m + "Cf of Vehicle No. : " + tno.Text + " will expire On : " + dateTimePickercf.Value.ToShortDateString() + "";
                                }
                                else
                                {
                                    m = m + "\nCf of Vehicle No. : " + tno.Text + " will expire On : " + dateTimePickercf.Value.ToShortDateString() + "";
                                }
                            }

                            if ((DateTime.Parse(DateTime.Now.ToShortDateString()).AddDays(15).CompareTo(DateTime.Parse(dateTimePickerpollution.Value.ToShortDateString()))) >= 0)
                            {
                                db.Ins_Up_Del("INSERT INTO [AVVMS].[dbo].[Vehicle_Notifications]([Vehicle],[Reason],[Remarks])VALUES('" + tno.Text + "','Pollution Certificate of Vehicle No. : " + tno.Text + " will expire On : " + dateTimePickerpollution.Value.ToShortDateString() + "','Expiration Date : " + dateTimePickerpollution.Value.ToShortDateString() + "')");

                                if (m.Equals(""))
                                {
                                    m = m + "Pollution Certificate of Vehicle No. : " + tno.Text + " will expire On : " + dateTimePickerpollution.Value.ToShortDateString() + "";
                                }
                                else
                                {
                                    m = m + "\nPollution Certificate of Vehicle No. : " + tno.Text + " will expire On : " + dateTimePickerpollution.Value.ToShortDateString() + "";
                                }
                            }

                            if ((DateTime.Parse(DateTime.Now.ToShortDateString()).AddDays(15).CompareTo(DateTime.Parse(dateTimePickerpermit.Value.ToShortDateString()))) >= 0)
                            {
                                db.Ins_Up_Del("INSERT INTO [AVVMS].[dbo].[Vehicle_Notifications]([Vehicle],[Reason],[Remarks])VALUES('" + tno.Text + "','Permit of Vehicle No. : " + tno.Text + " will expire On : " + dateTimePickerpermit.Value.ToShortDateString() + "','Expiration Date : " + dateTimePickerpermit.Value.ToShortDateString() + "')");

                                if (m.Equals(""))
                                {
                                    m = m + "Permit of Vehicle No. : " + tno.Text + " will expire On : " + dateTimePickerpermit.Value.ToShortDateString() + "";
                                }
                                else
                                {
                                    m = m + "\nPermit of Vehicle No. : " + tno.Text + " will expire On : " + dateTimePickerpermit.Value.ToShortDateString() + "";
                                }
                            }

                            if ((DateTime.Parse(DateTime.Now.ToShortDateString()).AddDays(15).CompareTo(DateTime.Parse(dateTimePickergreen.Value.ToShortDateString()))) >= 0)
                            {
                                db.Ins_Up_Del("INSERT INTO [AVVMS].[dbo].[Vehicle_Notifications]([Vehicle],[Reason],[Remarks])VALUES('" + tno.Text + "','Green Tax Certificate of Vehicle No. : " + tno.Text + " will expire On : " + dateTimePickergreen.Value.ToShortDateString() + "','Expiration Date : " + dateTimePickergreen.Value.ToShortDateString() + "')");

                                if (m.Equals(""))
                                {
                                    m = m + "Green Tax Certificate of Vehicle No. : " + tno.Text + " will expire On : " + dateTimePickergreen.Value.ToShortDateString() + "";
                                }
                                else
                                {
                                    m = m + "\nGreen Tax Certificate of Vehicle No. : " + tno.Text + " will expire On : " + dateTimePickergreen.Value.ToShortDateString() + "";
                                }
                            }

                            if (!n.Equals(""))
                            {
                                if (m.Equals(""))
                                {
                                    m = m + n;
                                }
                                else
                                {
                                    m = m + "\n" + n;
                                }
                            }

                            if (!m.Equals(""))
                            {
                                db.Ins_Up_Del("UPDATE [AVVMS].[dbo].[Vehicles]SET [status] = 'On Certificate Expiration' WHERE [Vehicle No.]='" + tno.Text + "'");
                                Program.pi.Display(m);
                            }



                            this.Close();
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("Try Again...\nReason : " + ex.Message);



                            db.close();
                        }
                    }
                    else
                    {
                        MessageBox.Show(message);
                    }
                }
                else
                {
                    String message = "";
                    int    c1f     = 0;


                    for (int i = 0; i < DGV_traffic_exception.Rows.Count; i++)
                    {
                        if (DGV_traffic_exception.Rows[i].Cells[0].Value.ToString().Equals(""))
                        {
                            c1f = 1;
                            if (message.Equals(""))
                            {
                                message = message + "Enter Description For Traffic Exception No. : " + (i + 1);
                            }
                            else
                            {
                                message = message + "\nEnter Description For Traffic Exception No. : " + (i + 1);
                            }
                        }
                        if (DGV_traffic_exception.Rows[i].Cells[1].Value.ToString().Equals(""))
                        {
                            c1f = 1;
                            if (message.Equals(""))
                            {
                                message = message + "Enter Expiry Date For Traffic Exception No. : " + (i + 1);
                            }
                            else
                            {
                                message = message + "\nEnter Expiry Date For Traffic Exception No. : " + (i + 1);
                            }
                        }
                    }
                    if (c1f == 0)
                    {
                        try
                        {
                            String n = "";
                            if (DGV_traffic_exception.Rows.Count != 0)
                            {
                                db.Ins_Up_Del("DELETE FROM [AVVMS].[dbo].[traffic exception] WHERE [Vehicle No.]='" + tno.Text + "'");

                                for (int i = 0; i < DGV_traffic_exception.Rows.Count; i++)
                                {
                                    db.Ins_Up_Del("INSERT INTO [AVVMS].[dbo].[traffic exception]([traffic exception due],[expiry date],[vehicle no.]) VALUES ('" + DGV_traffic_exception.Rows[i].Cells[0].Value.ToString() + "','" + DGV_traffic_exception.Rows[i].Cells[1].Value.ToString() + "' ,'" + tno.Text + "')");

                                    if ((DateTime.Parse(DateTime.Now.ToShortDateString()).AddDays(15).CompareTo(DateTime.Parse(DGV_traffic_exception.Rows[i].Cells[1].Value.ToString()))) >= 0)
                                    {
                                        db.Ins_Up_Del("INSERT INTO [AVVMS].[dbo].[Vehicle_Notifications]([Vehicle],[Reason],[Remarks])VALUES('" + tno.Text + "','Traffic Exception Due Certificate-" + DGV_traffic_exception.Rows[i].Cells[0].Value.ToString() + " of Vehicle No. : " + tno.Text + " will expire On : " + DGV_traffic_exception.Rows[i].Cells[1].Value.ToString() + "','Expiration Date : " + DGV_traffic_exception.Rows[i].Cells[1].Value.ToString() + "')");
                                        if (n.Equals(""))
                                        {
                                            n = n + "Traffic Exception Due Certificate-" + DGV_traffic_exception.Rows[i].Cells[0].Value.ToString() + " of Vehicle No. : " + tno.Text + " will expire On : " + DGV_traffic_exception.Rows[i].Cells[1].Value.ToString() + "";
                                        }
                                        else
                                        {
                                            n = n + "\nTraffic Exception Due Certificate-" + DGV_traffic_exception.Rows[i].Cells[0].Value.ToString() + " of Vehicle No. : " + tno.Text + " will expire On : " + DGV_traffic_exception.Rows[i].Cells[1].Value.ToString() + "";
                                        }
                                    }
                                }
                            }



                            db.Ins_Up_Del("UPDATE [AVVMS].[dbo].[Vehicles] SET [RC Expiry date] = '" + dateTimePickerrc.Value.ToShortDateString() + "',[CF date] = '" + dateTimePickercf.Value.ToShortDateString() + "',[Pollution Certificate Expiry date] = '" + dateTimePickerpollution.Value.ToShortDateString() + "',[Permit Expiry date] = '" + dateTimePickerpermit.Value.ToShortDateString() + "',[Green Tax Expiry date] = '" + dateTimePickergreen.Value.ToShortDateString() + "' WHERE [Vehicle No.]='" + tno.Text + "'");



                            MessageBox.Show("Updated Successfully");


                            String m = "";



                            if ((DateTime.Parse(DateTime.Now.ToShortDateString()).AddDays(15).CompareTo(DateTime.Parse(dateTimePickerrc.Value.ToShortDateString()))) >= 0)
                            {
                                db.Ins_Up_Del("INSERT INTO [AVVMS].[dbo].[Vehicle_Notifications]([Vehicle],[Reason],[Remarks])VALUES('" + tno.Text + "','RC of Vehicle No. : " + tno.Text + " will expire On : " + dateTimePickerrc.Value.ToShortDateString() + "','Expiration Date : " + dateTimePickerrc.Value.ToShortDateString() + "')");

                                if (m.Equals(""))
                                {
                                    m = m + "RC of Vehicle No. : " + tno.Text + " will expire On : " + dateTimePickerrc.Value.ToShortDateString() + "";
                                }
                                else
                                {
                                    m = m + "\nRC of Vehicle No. : " + tno.Text + " will expire On : " + dateTimePickerrc.Value.ToShortDateString() + "";
                                }
                            }



                            if ((DateTime.Parse(DateTime.Now.ToShortDateString()).AddDays(15).CompareTo(DateTime.Parse(dateTimePickercf.Value.ToShortDateString()))) >= 0)
                            {
                                db.Ins_Up_Del("INSERT INTO [AVVMS].[dbo].[Vehicle_Notifications]([Vehicle],[Reason],[Remarks])VALUES('" + tno.Text + "','CF of Vehicle No. : " + tno.Text + " will expire On : " + dateTimePickercf.Value.ToShortDateString() + "','Expiration Date : " + dateTimePickercf.Value.ToShortDateString() + "')");

                                if (m.Equals(""))
                                {
                                    m = m + "Cf of Vehicle No. : " + tno.Text + " will expire On : " + dateTimePickercf.Value.ToShortDateString() + "";
                                }
                                else
                                {
                                    m = m + "\nCf of Vehicle No. : " + tno.Text + " will expire On : " + dateTimePickercf.Value.ToShortDateString() + "";
                                }
                            }


                            if ((DateTime.Parse(DateTime.Now.ToShortDateString()).AddDays(15).CompareTo(DateTime.Parse(dateTimePickerpollution.Value.ToShortDateString()))) >= 0)
                            {
                                db.Ins_Up_Del("INSERT INTO [AVVMS].[dbo].[Vehicle_Notifications]([Vehicle],[Reason],[Remarks])VALUES('" + tno.Text + "','Pollution Certificate of Vehicle No. : " + tno.Text + " will expire On : " + dateTimePickerpollution.Value.ToShortDateString() + "','Expiration Date : " + dateTimePickerpollution.Value.ToShortDateString() + "')");

                                if (m.Equals(""))
                                {
                                    m = m + "Pollution Certificate of Vehicle No. : " + tno.Text + " will expire On : " + dateTimePickerpollution.Value.ToShortDateString() + "";
                                }
                                else
                                {
                                    m = m + "\nPollution Certificate of Vehicle No. : " + tno.Text + " will expire On : " + dateTimePickerpollution.Value.ToShortDateString() + "";
                                }
                            }


                            if ((DateTime.Parse(DateTime.Now.ToShortDateString()).AddDays(15).CompareTo(DateTime.Parse(dateTimePickerpermit.Value.ToShortDateString()))) >= 0)
                            {
                                db.Ins_Up_Del("INSERT INTO [AVVMS].[dbo].[Vehicle_Notifications]([Vehicle],[Reason],[Remarks])VALUES('" + tno.Text + "','Permit of Vehicle No. : " + tno.Text + " will expire On : " + dateTimePickerpermit.Value.ToShortDateString() + "','Expiration Date : " + dateTimePickerpermit.Value.ToShortDateString() + "')");

                                if (m.Equals(""))
                                {
                                    m = m + "Permit of Vehicle No. : " + tno.Text + " will expire On : " + dateTimePickerpermit.Value.ToShortDateString() + "";
                                }
                                else
                                {
                                    m = m + "\nPermit of Vehicle No. : " + tno.Text + " will expire On : " + dateTimePickerpermit.Value.ToShortDateString() + "";
                                }
                            }


                            if ((DateTime.Parse(DateTime.Now.ToShortDateString()).AddDays(15).CompareTo(DateTime.Parse(dateTimePickergreen.Value.ToShortDateString()))) >= 0)
                            {
                                db.Ins_Up_Del("INSERT INTO [AVVMS].[dbo].[Vehicle_Notifications]([Vehicle],[Reason],[Remarks])VALUES('" + tno.Text + "','Green Tax Certificate of Vehicle No. : " + tno.Text + " will expire On : " + dateTimePickergreen.Value.ToShortDateString() + "','Expiration Date : " + dateTimePickergreen.Value.ToShortDateString() + "')");

                                if (m.Equals(""))
                                {
                                    m = m + "Green Tax Certificate of Vehicle No. : " + tno.Text + " will expire On : " + dateTimePickergreen.Value.ToShortDateString() + "";
                                }
                                else
                                {
                                    m = m + "\nGreen Tax Certificate of Vehicle No. : " + tno.Text + " will expire On : " + dateTimePickergreen.Value.ToShortDateString() + "";
                                }
                            }

                            if (!n.Equals(""))
                            {
                                if (m.Equals(""))
                                {
                                    m = m + n;
                                }
                                else
                                {
                                    m = m + "\n" + n;
                                }
                            }

                            if (!m.Equals(""))
                            {
                                db.Ins_Up_Del("UPDATE [AVVMS].[dbo].[Vehicles]SET [status] = 'On Certificate Expiration' WHERE [Vehicle No.]='" + tno.Text + "'");
                                Program.pi.Display(m);
                            }
                            else
                            {
                                if (db.GetValue("SELECT[Status]FROM [AVVMS].[dbo].[Vehicles] where [Vehicle No.]='" + tno.Text + "'").Equals("On Certificate Expiration"))
                                {
                                    db.Ins_Up_Del("UPDATE [AVVMS].[dbo].[Vehicles]SET [status] = 'Available' WHERE [Vehicle No.]='" + tno.Text + "'");
                                }
                            }



                            this.Close();
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("Try Again...\nReason : " + ex.Message);



                            db.close();
                        }
                    }
                    else
                    {
                        MessageBox.Show(message);
                    }
                }
            }
        }