示例#1
0
        private void applybutton_Click(object sender, EventArgs e)
        {
            LoadData database = new LoadData();

            admin = new Admin(namelist);
            switch (applybutton.Text)
            {
            case "Add":
                database.runsqlcmd("insert into login(staff_no) values('" + staffnumbertextBox.Text + "');");

                database.runsqlcmd("insert into staffstatus (staff_name, userId, staff_no, grade, unit, cc ) values('" +
                                   staffnametextBox.Text + "'," +
                                   database.getTable("select LAST(userId)  from login", "login").Rows[0][0] + ",'" +
                                   staffnumbertextBox.Text + "','" +
                                   gradecomboBox.Text + "','" +
                                   unitcomboBox.Text + "','" +
                                   CCcomboBox.Text +
                                   "');");
                admin.createNameList();
                this.Close();
                break;

            case "Moditfly":
                database.runsqlcmd("update staffstatus set staff_name = '" + staffnametextBox.Text +
                                   "', staff_no = '" + staffnumbertextBox.Text + "', " +
                                   "grade = '" + gradecomboBox.Text + "'," +
                                   "unit = '" + unitcomboBox.Text + "'," +
                                   "cc = '" + CCcomboBox.Text + "' " +
                                   "where staffId = " + staffId
                                   );
                admin.createNameList();
                this.Close();
                break;
            }
        }
示例#2
0
        private void applyButton_Click(object sender, EventArgs e)
        {
            string ss = "";

            foreach (string s in commentBox.Text.Split(new[] { "\n" }, StringSplitOptions.None))
            {
                if (s.Length > 50)
                {
                    int i;
                    for (i = 50; i < s.Length; i = i + 50)
                    {
                        ss += s.Substring(i - 50, 50) + "\n";
                    }
                    ss += s.Substring(i - 50, s.Length - (i - 50));
                }
                else
                {
                    ss += s + "\n";
                }
            }
            commentBox.Text = ss;

            if (isnewcomment)
            {
                database.runsqlcmd("insert into comment (comment, dateoflast, userId) values ('" + ss + "','" + datetime + "','" + userId + "') ;");
                dgvc.Tag = database.getTable("select * from comment where userId = " + userId.ToString() + " and dateoflast =CDate('" + datetime + "');", "comment").Rows[0][0];
            }
            else
            {
                database.runsqlcmd("update comment set comment ='" + ss + "'" + " where commentId =" + commentId + ";");
            }
            isapply = true;
            this.Close();
        }
示例#3
0
        public void saveStatus(timepicker tp, int userId, double oldbalance)
        {
            LoadData database = new LoadData();

            database.runsqlcmd("update comment set " +
                               "dutystart = CDate('" + tp.start.Value.ToString() +
                               "') , dutyend = CDate('" + tp.end.Value.ToString() +
                               "') , otstart = CDate('" + tp.otstart.Value.ToString() +
                               "') , otend = CDate('" + tp.otend.Value.ToString() +
                               "') , toiltaked = CDate('" + tp.toiltaked.Value.ToString() +
                               "') , toiladded = CDate('" + tp.toiladded.Value.ToString() +
                               "') , isA = " + tp.isA.Checked +
                               " , isN = " + tp.isN.Checked +
                               " , isM = " + tp.isM.Checked +
                               " , isECO = " + tp.isECO.Checked +
                               " , isDrive = " + tp.isDrive.Checked +
                               " , isSPday = " + tp.isSPday.Checked +
                               " , isStandby = " + tp.isStandby.Checked +
                               " where commentId = " + commentId.ToString());
            database.runsqlcmd("update staffstatus set toil_balance = toil_balance +" + (Convert.ToDouble(((tp.toiladded.Value - tp.toiltaked.Value).Hours + "." + Math.Abs(((tp.toiladded.Value - tp.toiltaked.Value).Minutes) * 10 / 60)).ToString()) - oldbalance) + " where userId =" + userId);
        }
示例#4
0
        private void duplicateToSelectDayToolStripMenuItem_Click(object sender, EventArgs e)
        {
            /*duplicate function*/

            duplicateToSelectDayToolStripMenuItem.Enabled = false;
            duplicateThisDayToolStripMenuItem.Enabled     = true;
            DataTable dt = database.getTable("select * from comment where commentId = " + neededDuplicateId + ";", "comment");


            int i = selectcells.Count - 1;

            foreach (DataGridViewCell dgvc in selectcells)
            {
                DateTime date = new DateTime();
                date = Convert.ToDateTime(calendar.getDateByCaleandar(dgvc.RowIndex, dgvc.ColumnIndex));
                string updatesqlCMD = "update comment set comment = '" + dt.Rows[0][1].ToString() +
                                      "', dutystart = '" + date.ToShortDateString() + " " + Convert.ToDateTime(dt.Rows[0][4]).ToShortTimeString() +
                                      "', dutyend = '" + date.ToShortDateString() + " " + Convert.ToDateTime(dt.Rows[0][5]).ToShortTimeString() +
                                      "', otstart = '" + date.ToShortDateString() + " " + nulltostring(dt.Rows[0][6].ToString()) +
                                      "', otend = '" + date.ToShortDateString() + " " + nulltostring(dt.Rows[0][7].ToString()) +
                                      "', toiltaked = '" + date.ToShortDateString() + " " + nulltostring(dt.Rows[0][8].ToString()) +
                                      "', toiladded = '" + date.ToShortDateString() + " " + nulltostring(dt.Rows[0][9].ToString()) +
                                      "', daystatus = '" + dt.Rows[0][10].ToString() +
                                      "', isA = " + Convert.ToBoolean(dt.Rows[0][11]) +
                                      ", isN = " + Convert.ToBoolean(dt.Rows[0][12]) +
                                      ", isM = " + Convert.ToBoolean(dt.Rows[0][13]) +
                                      ", isECO = " + Convert.ToBoolean(dt.Rows[0][14]) +
                                      ", isDrive = " + Convert.ToBoolean(dt.Rows[0][15]) +
                                      ", isSPday = " + Convert.ToBoolean(dt.Rows[0][16]) +
                                      " where commentId =";

                if (dgvc.Tag == null)
                {
                    string insertsqlCMD = "insert into comment (comment, dateoflast, userId, dutystart, dutyend, otstart, otend, toiltaked, toiladded, daystatus, isA, isN, isM, isECO, isDrive, isSPday, isStandby) values ('" +
                                          dt.Rows[0][1].ToString() +
                                          "', CDate('" + date.ToString() +
                                          "'), " + dt.Rows[0][3].ToString() +
                                          ", CDate('" + date.ToShortDateString() + " " + Convert.ToDateTime(dt.Rows[0][4]).ToShortTimeString() +
                                          "'), CDate('" + date.ToShortDateString() + " " + Convert.ToDateTime(dt.Rows[0][5]).ToShortTimeString() +
                                          "'), CDate('" + date.ToShortDateString() + " " + nulltostring(dt.Rows[0][6]) +
                                          "'), CDate('" + date.ToShortDateString() + " " + nulltostring(dt.Rows[0][7]) +
                                          "'), CDate('" + date.ToShortDateString() + " " + nulltostring(dt.Rows[0][8]) +
                                          "'), CDate('" + date.ToShortDateString() + " " + nulltostring(dt.Rows[0][9]) +
                                          "'), '" + (dt.Rows[0][10]).ToString() +
                                          "', " + Convert.ToBoolean(dt.Rows[0][11]) +
                                          ", " + Convert.ToBoolean(dt.Rows[0][12]) +
                                          ", " + Convert.ToBoolean(dt.Rows[0][13]) +
                                          ", " + Convert.ToBoolean(dt.Rows[0][14]) +
                                          ", " + Convert.ToBoolean(dt.Rows[0][15]) +
                                          ", " + Convert.ToBoolean(dt.Rows[0][16]) +
                                          ", " + Convert.ToBoolean(dt.Rows[0][17]) +
                                          ");";
                    database.runsqlcmd(insertsqlCMD);
                    database.runsqlcmd("update staffstatus set al_balance = al_balance + 1  where userId =" + userId);
                }
                else
                {
                    /*****************if the origion day status isn't al *******************/

                    if (dt.Rows[0][10].ToString().Equals("Annual Leave") && !database.getTable("select * from comment where commentId = " + dgvc.Tag + ";", "comment").Rows[0]["daystatus"].ToString().Equals("Annual Leave"))
                    {
                        database.runsqlcmd("update staffstatus set al_balance = al_balance + 1 where userId =" + userId);
                    }

                    updatesqlCMD = updatesqlCMD + dgvc.Tag + ";";
                    database.runsqlcmd(updatesqlCMD);
                }
                double   oldtoil = 0.00;
                double   newtoil = 0.00;
                DateTime toiladded;
                DateTime toiltaked;
                try
                {
                    toiladded = Convert.ToDateTime(database.getTable("select * from comment where commentId =  " + dgvc.Tag + ";", "comment").Rows[0]["toiladded"]);
                    toiltaked = Convert.ToDateTime(database.getTable("select * from comment where commentId =  " + dgvc.Tag + ";", "comment").Rows[0]["toiltaked"]);
                    oldtoil   = Convert.ToDouble((toiladded - toiltaked).Hours.ToString() + "." + (((toiladded - toiltaked).Minutes) * 10 / 60).ToString());
                }
                catch (Exception ex)
                {
                    oldtoil = 0.0;
                }
                toiladded = Convert.ToDateTime(dt.Rows[0]["toiladded"]);
                toiltaked = Convert.ToDateTime(dt.Rows[0]["toiltaked"]);
                newtoil   = Convert.ToDouble((toiladded - toiltaked).Hours.ToString() + "." + (((toiladded - toiltaked).Minutes) * 10 / 60).ToString());
                database.runsqlcmd("Update staffstatus set toil_balance = toil_balance +" + (newtoil - oldtoil).ToString() + " where userId = " + userId);
            }

            calendar.createCalendar(monthToInt(MonthcomboBox.Text), DateTime.Now.Year, userId.ToString());
        }