Пример #1
0
        private void Yellow_label_mouse_Click(object sender, MouseEventArgs e)
        {
            reading_firstDay_table();
            reading_SecondDay_table();

            dataBase db = new dataBase();
            string date = string.Format("{0:yyyy-MM-dd}", dateTimePicker1.Value);
            string read_data = db.GetPlace(date);
            if (read_data != null)
            {
                string[] arr = read_data.Split('!');
                string dt = arr[0];
                int ln = Convert.ToInt32(arr[1]);
                dateTimePicker1.Value = Convert.ToDateTime(dt);
                dateTimePicker2.Value = dateTimePicker1.Value.AddDays(+1);
                string kj = string.Format("{0:yyyy-MM-dd}", dateTimePicker1.Value);
                loading_page_Date_Checker(kj);
                string kl = string.Format("{0:yyyy-MM-dd}", dateTimePicker2.Value);
                loading_page_RightDate_Checkeer(kl);

                pink = --ln;
                num = --ln;
            }
            if (num == 20)
            {

                // dateTimePicker1.Value = dateTimePicker1.Value.AddDays(1);
                pictureBox2.Enabled = false;
                pictureBox1.Enabled = false;

                reading_firstDay_table();
                reading_SecondDay_table();

                dateTimePicker2.Value = dateTimePicker2.Value.AddDays(1);
                dateTimePicker1.Value = dateTimePicker1.Value.AddDays(1);
                string kj = string.Format("{0:yyyy-MM-dd}", dateTimePicker1.Value);
                loading_page_Date_Checker(kj);
                string kl = string.Format("{0:yyyy-MM-dd}", dateTimePicker2.Value);
                loading_page_RightDate_Checkeer(kl);

                pictureBox2.Enabled = true;
                pictureBox1.Enabled = true;
                num = 10;
            }
            {
                if (pink == 10)
                {
                    yellow_change_column = yellow_change_column + 12;
                    pink_change_Column = pink_change_Column + 12;
                    pink = 0;
                }
                yellow = ++pink;
                num++;
                Console.WriteLine("Yellow Column Number = " + yellow);
                Panel p1 = new Panel();

                //            p1.Location = new System.Drawing.Point(0, 114);
                p1.Name = "p1";
                int height = tableLayoutPanel1.Height / 12;
                int width = tableLayoutPanel1.Width / 22;
                p1.Size = new System.Drawing.Size(width, height);
                p1.TabIndex = 7;

                // label4.Enabled = false;

                textBox_3 = new TextBox();
                textBox_2 = new TextBox();
                textBox_1 = new TextBox();

                Label l1 = new Label();
                Label l2 = new Label();
                Label l3 = new Label();

                textBox_1.BackColor = System.Drawing.Color.Yellow;
                textBox_2.BackColor = System.Drawing.Color.Yellow;
                textBox_3.BackColor = System.Drawing.Color.Yellow;

                p1.Location = new Point(400,300);
                p1.Visible = true;
                p1.BackColor = System.Drawing.Color.Yellow;
                tableLayoutPanel1.Controls.Add(p1, yellow_change_column, yellow);

                p1.AllowDrop = true;
                p1.BorderStyle = System.Windows.Forms.BorderStyle.None;

                p1.Controls.Add(textBox_3);
                p1.Controls.Add(textBox_2);
                p1.Controls.Add(textBox_1);

                //
                // TextBox3
                //
                textBox_3.Font = new System.Drawing.Font("Microsoft Sans Serif", 6F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                textBox_3.Location = new System.Drawing.Point(-2, 22);
                textBox_3.Margin = new System.Windows.Forms.Padding(0);
                textBox_3.Multiline = true;
                textBox_3.Name = "textBox3";
                textBox_3.TextAlign = HorizontalAlignment.Left;
                textBox_3.Size = new System.Drawing.Size(p1.Width - 13, 42);
                textBox_3.TabIndex = 2;
                textBox_3.Text = "";
                textBox_3.BorderStyle = BorderStyle.None;

                textBox_3.KeyDown += new System.Windows.Forms.KeyEventHandler(textBox_3_KeyDown);

                //
                // textBox2
                //
                textBox_2.Font = new System.Drawing.Font("Microsoft Sans Serif", 6F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                textBox_2.Location = new System.Drawing.Point(0, 12);
                textBox_2.Margin = new System.Windows.Forms.Padding(0);
                textBox_2.Multiline = false;
                textBox_2.Name = "textBox2";
                textBox_2.TextAlign = HorizontalAlignment.Left;
                textBox_2.Size = new System.Drawing.Size(p1.Width - 14, 8);
                textBox_2.TabIndex = 1;
                textBox_2.Text = "";
                textBox_2.BorderStyle = BorderStyle.None;

                textBox_2.KeyDown += new System.Windows.Forms.KeyEventHandler(textBox_2_KeyDown);

                //
                // textBox1
                //
                textBox_1.Font = new System.Drawing.Font("Microsoft Sans Serif", 6F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                textBox_1.Location = new System.Drawing.Point(0, 0);
                textBox_1.Margin = new System.Windows.Forms.Padding(0);
                textBox_1.Multiline = false;
                textBox_1.Name = "textBox1";
                textBox_1.TextAlign = HorizontalAlignment.Left;
                textBox_1.ShortcutsEnabled = false;
                textBox_1.Size = new System.Drawing.Size(p1.Width, 12);
                textBox_1.TabIndex = 0;
                textBox_1.Text = "";
                textBox_1.BorderStyle = BorderStyle.None;

                textBox_1.KeyDown += new System.Windows.Forms.KeyEventHandler(textBox_1_KeyDown);

                p1.Controls.Add(textBox_1);
                p1.Controls.Add(textBox_2);
                p1.Controls.Add(textBox_3);

                // Mouse Clicks
                p1.MouseClick += new System.Windows.Forms.MouseEventHandler(p1_yellow_MouseClick);
                p1.MouseDown += new System.Windows.Forms.MouseEventHandler(p1_MouseDown);
                p1.MouseMove += new System.Windows.Forms.MouseEventHandler(p1_yellow_MouseMove);
                p1.MouseUp += new System.Windows.Forms.MouseEventHandler(p1_MouseUp);

                //
                // Label1
                //
                l1.Size = new System.Drawing.Size(p1.Width - 42, p1.Height - 45);
                l1.BackColor = System.Drawing.Color.Yellow;
                l1.BorderStyle = BorderStyle.FixedSingle;
                l1.Location = new System.Drawing.Point(43, 12);

                p1.Controls.Add(l1);
                l1.Visible = true;

                //
                // Label2
                //
                l2.Size = new System.Drawing.Size(p1.Width - 42, p1.Height - 45);
                l2.BackColor = System.Drawing.Color.Yellow;
                l2.BorderStyle = BorderStyle.FixedSingle;
                l2.Location = new System.Drawing.Point(43, 18);

                p1.Controls.Add(l2);
                l2.Visible = true;

                //
                // Label3
                //
                l3.Size = new System.Drawing.Size(p1.Width - 42, p1.Height - 45);
                l3.BackColor = System.Drawing.Color.Yellow;
                l3.BorderStyle = BorderStyle.FixedSingle;
                l3.Location = new System.Drawing.Point(43, 24);

                p1.Controls.Add(l3);

                l3.Visible = true;

                l1.MouseClick += yellow_label1_MouseClick;
                l2.MouseClick += yellow_label2_MouseClick;
                l3.MouseClick += yellow_label3_MouseClick;

                // Delete Button Pressed
                p1.KeyDown += new System.Windows.Forms.KeyEventHandler(p1_KeyDown);
            }
        }
Пример #2
0
        private void loading_page_RightDate_Checkeer(string kl)
        {
            dataBase db = new dataBase();
            string dat = string.Format("{0:yyyy-MM-dd}", dateTimePicker1.Value);
            kl=string.Format("{0:yyyy-MM-dd}", kl);
            if (obj.search_date_of_left_day(kl, 0) == true)
            {
            //                MessageBox.Show(kl +" Date is Found");
                clear_right_date();
                for (int num = 0; num < 12 ; num++)
                {
                    read_secondDay_from_DB(kl, num);
                }
            }
            else
            {
              //             MessageBox.Show(kl + " Date Not Found");

                for (int i = 0; i < tableLayoutPanel1.RowCount; i++)
                {
                    //for (int j = 0; j < tableLayoutPanel1.ColumnCount / 2; j++)
                    for (int j = tableLayoutPanel1.ColumnCount/2; j < tableLayoutPanel1.ColumnCount; j++)
                    {
                        if (i == 0 || j == tableLayoutPanel1.ColumnCount/2 )
                        {

                            #region #region -----------------------add name for previous or next date available names----------------------------------------------------
                            if (i == 0 && j==tableLayoutPanel1.ColumnCount / 2)
                            {
                                string nowdt = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
                                //this code for get future date to insert name only  if selected date is less than now date
                                if (Convert.ToDateTime(dat) < Convert.ToDateTime(nowdt))
                                {
                                    string ds = db.GetMinFutureDate(dat);
                                    if (ds != "")
                                    {
                                        for (int jj = tableLayoutPanel1.ColumnCount / 2; jj < tableLayoutPanel1.ColumnCount; jj++)
                                        {
                                            tableLayoutPanel1.Controls.Remove(tableLayoutPanel1.GetControlFromPosition(jj, i));
                                        }
                                        read_secondDay_from_DB1(ds, 0);
                                    }
                                }
                                //this code for get past date to insert name only in selected date is greater than now date
                                else if ((Convert.ToDateTime(dat) > Convert.ToDateTime(nowdt)))
                                {
                                    string ds = db.GetMinPastDate(dat);
                                    if (ds != "")
                                    {
                                        for (int jj = tableLayoutPanel1.ColumnCount / 2; jj < tableLayoutPanel1.ColumnCount; jj++)
                                        {
                                            tableLayoutPanel1.Controls.Remove(tableLayoutPanel1.GetControlFromPosition(jj, i));
                                        }
                                        read_secondDay_from_DB1(ds, 0);
                                    }
                                }

                            }
                            #endregion trial and error2

                        }
                        else
                        {
                            //     MessageBox.Show("Cleaning "+i+" = row and column = "+j);
                            tableLayoutPanel1.Controls.Remove(tableLayoutPanel1.GetControlFromPosition(j, i));
                        }
                    }
                }
            }
        }
Пример #3
0
        //Reading Right Half
        private void reading_SecondDay_table()
        {
            dataBase db = new dataBase();
            for (int i = 0; i < this.tableLayoutPanel1.RowCount; i++)
               {
                for (int j = this.tableLayoutPanel1.ColumnCount / 2; j < this.tableLayoutPanel1.ColumnCount ; j++)
                {
                    Control c = this.tableLayoutPanel1.GetControlFromPosition(j, i);

                    if (c == null)
                    {
                        storeing_firstday[col++] = "";
                    }
                    else if (c != null && c is Label)
                    {
                        storeing_firstday[col++] = c.Text.Trim();
                    }
                    else if (c != null && c is TextBox)
                    {
                        storeing_firstday[col++] = c.Text.Trim();
                    }
                    else if (c != null && c is Panel)
                    {
                        string panel_Color = c.BackColor.ToString();
                        string first = panel_Color.Split('[', ']')[1];
                        kll = first;
                        string l;
                        foreach (Control control in c.Controls)
                        {
                            if (control is TextBox)
                            {
                                l = control.Text.Trim();
                                kll = kll + "!" + l;
                            }
                            else if (control is Label)
                            {
                                string s = control.BackColor.ToString();
                                string output = s.Split('[', ']')[1];
                                kll = kll + "!" + output;
                                iteration++;
                            }
                        }
                        storeing_firstday[col++] = kll;
                        first = null;
                        l = null;
                        kll = null;
                    }
                }
                //DateTime dat1 = Convert.ToDateTime(dateTimePicker2.Text.ToString());
                //string dat = dat1.ToShortDateString();
                string dat = string.Format("{0:yyyy-MM-dd}", dateTimePicker2.Value);
                //DateTime dat1 = DateTime.ParseExact(dateTimePicker2.Value.ToShortDateString(),"dd/MM/yyyy",null);
                col = 0;
                if (db.search_date_of_left_day(dat, line1))
                {
                    db.update_first_table_data(dat, line1, storeing_firstday[0], storeing_firstday[1], storeing_firstday[2], storeing_firstday[3], storeing_firstday[4], storeing_firstday[5], storeing_firstday[6], storeing_firstday[7], storeing_firstday[8], storeing_firstday[9], storeing_firstday[10],storeing_firstday[11]);
                    line1++;

                }
                else
                {
                    db.add_date_firstDay(dat, line1, storeing_firstday[0], storeing_firstday[1], storeing_firstday[2], storeing_firstday[3], storeing_firstday[4], storeing_firstday[5], storeing_firstday[6], storeing_firstday[7], storeing_firstday[8], storeing_firstday[9], storeing_firstday[10],storeing_firstday[11]);
                    line1++;
                }
            }
            line1 = 0;
        }
Пример #4
0
        private void loading_page_Date_Checker(string kj)
        {
            //check whether data is available for date if yes
            //kj = string.Format("{0:yyyy-MM-dd}", kj);
            dataBase db = new dataBase();
            string dat = string.Format("{0:yyyy-MM-dd}", dateTimePicker1.Value);
            if (obj.search_date_of_left_day(kj, 0) == true)
                {
                   // MessageBox.Show(kj + " Date is Found");
                    clear_left_date();
                    for (int num = 0; num < tableLayoutPanel1.ColumnCount / 2; num++)
                    {
                        read_firstDay_from_DB(kj, num);
                    }
                }
                else//if data is not avialable for date
                {
                   // MessageBox.Show(kj + " Date Not Found");
                    for (int i = 0; i < tableLayoutPanel1.RowCount; i++)
                    {
                        for (int j = 0; j < tableLayoutPanel1.ColumnCount / 2; j++)
                        {
                            if (i == 0 || j == 0)
                            {
                                #region -----------------------add name for previous or next date available names----------------------------------------------------
                                if (i==0 && j==0)
                                {
                                    string nowdt = string.Format("{0:yyyy-MM-dd}", DateTime.Now);

                                    //this code for get future date to insert name only  if selected date is less than now date
                                        if (Convert.ToDateTime(dat) < Convert.ToDateTime(nowdt))
                                        {
                                            string ds = db.GetMinFutureDate(dat);
                                            if (ds != "")
                                            {
                                                for (int jj = 0; jj < tableLayoutPanel1.ColumnCount / 2; jj++)
                                                {
                                                    tableLayoutPanel1.Controls.Remove(tableLayoutPanel1.GetControlFromPosition(jj, i));
                                                }

                                                    read_firstDay_from_DB1(ds, 0);

                                            }
                                        }
                                        //this code for get past date to insert name only in selected date is greater than now date
                                        else if ((Convert.ToDateTime(dat) > Convert.ToDateTime(nowdt)))
                                        {
                                            string ds = db.GetMinPastDate(dat);
                                            if (ds != "")
                                            {
                                                for (int jj = 0; jj < tableLayoutPanel1.ColumnCount / 2; jj++)
                                                {
                                                    tableLayoutPanel1.Controls.Remove(tableLayoutPanel1.GetControlFromPosition(jj, i));
                                                }

                                                    read_firstDay_from_DB1(ds, 0);

                                            }
                                        }
                                }
                                #endregion end tiral and error

                            }
                            else
                            {

                                tableLayoutPanel1.Controls.Remove(tableLayoutPanel1.GetControlFromPosition(j, i));
                                //MessageBox.Show("Deleting");
                            }
                        }
                    }
                }
        }