Beispiel #1
0
        public static bool ModifyRight()
        {
            ConnDB conn = new ConnDB();
            string sql;
            bool   right = false;

            sql = "select m.permission from COST_USER i left join COST_USER_ROLE r on i.CID = r.USER_ID and r.HAVE_RIGHT = 'true' left join COST_ROLE_PERMISSION p on r.ROLE_ID = p.ROLE_ID and p.HAVE_RIGHT = 'true' left join COST_MODULE_PERMISSION m on p.PERMISSION_ID = m.CID where i.CNAME = '" + Logon.GetCname() + "' and m.module_name = '临时工基本信息'";
            DataSet ds = conn.ReturnDataSet(sql);

            for (int j = 0; j < ds.Tables[0].Rows.Count; j++)
            {
                if (ds.Tables[0].Rows[j][0].ToString() == "修改")
                {
                    right = true;
                    break;
                }
                else
                {
                    right = false;
                }
            }
            conn.Close();
            return(right);
        }
Beispiel #2
0
        private void simpleButtonOK_Click(object sender, EventArgs e)
        {
            ConnDB  conn = new ConnDB();
            string  sql, month, cdate;
            bool    isok = false, closed = false;
            DataSet ds;

            cdate = dateTimePickerDateBegin.Text.ToString();
            if (Convert.ToDateTime(cdate) > DayOfMonth(Convert.ToDateTime(cdate)))
            {
                month = NextMonth(Convert.ToDateTime(cdate));
            }
            else
            {
                month = Convert.ToDateTime(cdate).ToString("yyyy-MM");
            }
            sql = "select closed from cost_temp_close where cmonth = '" + month + "'";
            ds  = conn.ReturnDataSet(sql);
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0][0].ToString() == "True")
                {
                    closed = true;
                }
            }
            bool right = TempEmpAttQuery.SubmitRight(textEditCno.Text.ToString().Trim());

            if (!right)
            {
            }
            else if (closed)
            {
                MessageBox.Show("该月考勤已经关闭,不能再提报!");
            }
            else if (textEditStatus.Text != "未提报" && textEditStatus.Text != "")
            {
                MessageBox.Show("已提报的记录,不能再提报!");
            }
            else if (comboBoxShift.Text.ToString().Trim() == "" || textEditCno.Text.ToString().Trim() == "" || textEditRest.Text.ToString().Trim() == "" || textEditRealHours.Text.ToString().Trim() == "" || textEditNormal.Text.ToString().Trim() == "")
            {
                MessageBox.Show("有关键信息为空,请检查!");
            }
            else if (this.Text == "异常提报" && comboBoxNGType.SelectedValue.ToString() == "")
            {
                MessageBox.Show("请选择异常类型!");
            }
            else
            {
                string checkdata = "select isnull(status,0) status from COST_TEMP_EMPLOYEE_ATTENDANCE  where isnull(isclose,0) = 0 and cno = '" + textEditCno.Text.ToString() + "' and begin_date = '" + dateTimePickerDateBegin.Text + "' and end_date = '" + dateTimePickerDateEnd.Text + "'";;
                ds = conn.ReturnDataSet(checkdata);
                if (begin_date != "")
                {
                    if (ds.Tables[0].Rows.Count > 0 && (Convert.ToDateTime(begin_date).ToString("yyyy-MM-dd") != dateTimePickerDateBegin.Text.ToString() || Convert.ToDateTime(end_date).ToString("yyyy-MM-dd") != dateTimePickerDateEnd.Text.ToString()))
                    {
                        MessageBox.Show("该出勤日期已经存在!");
                    }
                    else
                    {
                        //TimeSpan ts = Convert.ToDateTime(dateTimePickerEnd.Text) - Convert.ToDateTime(dateTimePickerBegin.Text);
                        //textEditRealHours.Text = Convert.ToString(ts.TotalHours - Convert.ToDouble(textEditRest.Text.ToString().Trim()));
                        sql  = "update COST_TEMP_EMPLOYEE_ATTENDANCE set shift = '" + comboBoxShift.SelectedValue.ToString() + "',begin_date = '" + dateTimePickerDateBegin.Text + "',end_date = '" + dateTimePickerDateEnd.Text + "',BEGIN_APPLY = '" + timeEditBegin.Text + "',END_APPLY = '" + timeEditEnd.Text + "',rest_hours = '" + textEditRest.Text.ToString().Trim() + "',hours = '" + textEditRealHours.Text.ToString().Trim() + "',normal_hours = '" + textEditNormal.Text.ToString().Trim() + "',overtime_hours = '" + textEditOverTime.Text.ToString().Trim() + "',REASON_OVERTIME='" + textEditReason.Text.ToString().Trim() + "',apply_user = '******',apply_time = '" + DateTime.Now.ToString() + "',ng_type = '" + comboBoxNGType.SelectedValue.ToString() + "',status = 1";
                        sql  = sql + " where cno = '" + cno + "' and begin_date = '" + begin_date + "' and end_date = '" + end_date + "' and isnull(isclose,0) = 0";
                        isok = conn.EditDatabase(sql);
                        if (isok)
                        {
                            MessageBox.Show("提报成功!");
                            TempEmpAttQuery.RefreshEX();
                            this.Close();
                        }
                        else
                        {
                            MessageBox.Show("失败!");
                        }
                    }
                }
                else
                {
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        MessageBox.Show("此员工该出勤日期已经存在,请直接选择相应记录进行提报!");
                    }
                    else
                    {
                        sql  = string.Format("Insert into COST_TEMP_EMPLOYEE_ATTENDANCE(cno,shift,begin_date,end_date,begin_apply,end_apply,rest_hours,hours,normal_hours,overtime_hours,reason_overtime,status,apply_user,apply_time,ng_type) Values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}')", textEditCno.Text.ToString().Trim(), comboBoxShift.SelectedValue.ToString(), dateTimePickerDateBegin.Text, dateTimePickerDateEnd.Text, timeEditBegin.Text, timeEditEnd.Text, textEditRest.Text.ToString().Trim(), textEditRealHours.Text.ToString().Trim(), textEditNormal.Text.ToString().Trim(), textEditOverTime.Text.ToString().Trim(), textEditReason.Text.ToString().Trim(), 1, Logon.GetCname(), DateTime.Now.ToString(), comboBoxNGType.SelectedValue.ToString());
                        isok = conn.EditDatabase(sql);
                        if (isok)
                        {
                            MessageBox.Show("异常提报成功!");
                            TempEmpAttQuery.RefreshEX();
                            this.Close();
                        }
                        else
                        {
                            MessageBox.Show("失败!");
                        }
                    }
                }
            }

            conn.Close();
        }