Ejemplo n.º 1
0
        //删除按钮
        private void button_delete_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("您确定要删除本条记录?", "警告!", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
            {
                if (dataGridView_application.CurrentRow == null)
                {
                    MessageBox.Show("什么都没选中!");
                    return;
                }
                int    selectedRowIndex = dataGridView_application.CurrentRow.Index;
                string appId            = dataGridView_application.Rows[selectedRowIndex].Cells[0].Value.ToString();

                string  sqlStr = string.Format(Globalconst.SELECT_APPSTATUS, appId);
                DataSet ds     = CADOConn.GetDataSet(sqlStr);
                string  status = ds.Tables[0].Rows[0][0].ToString();
                if (status.Equals(Globalconst.SUCCESS))
                {
                    MessageBox.Show("档案已借出,该条预约记录无法删除!");
                    return;
                }


                sqlStr = string.Format(Globalconst.DELETE_APPLICATION, appId);
                CADOConn.ExecuteSQL(sqlStr);
                loadDATA();
            }
        }
        //维护状态:确定档案是已经借出去了
        private void button_lend_Click(object sender, EventArgs e)
        {
            if (dataGridView_admin.CurrentRow == null)
            {
                MessageBox.Show("什么都没选中!");
                return;
            }
            int    select_index = dataGridView_admin.CurrentRow.Index;
            string appid        = dataGridView_admin.Rows[select_index].Cells[0].Value.ToString();
            string objNameCode  = dataGridView_admin.Rows[select_index].Cells[2].Value.ToString();

            string[] temp    = objNameCode.Split('(');
            string   objCode = temp[1];

            objCode = objCode.Substring(0, 10);

            //更新档案状态
            string sqlStr = string.Format(Globalconst.UPDATE_DOCUMENT, Globalconst.NOT_ON_SHELF, objCode);

            CADOConn.ExecuteSQL(sqlStr);

            //更新预约状态
            sqlStr = string.Format(Globalconst.UPDATE_APPLICATION, Globalconst.SUCCESS, appid);
            CADOConn.ExecuteSQL(sqlStr);

            //生成事件记录
            string data = System.DateTime.Now.Date.ToString("yyyyMMdd");

            sqlStr = string.Format(Globalconst.INSERT_EVENT, Globalconst.LEND, objCode, appid, Program.curUser.UserName, data);
            CADOConn.ExecuteSQL(sqlStr);

            MessageBox.Show("存档成功!");

            loadData();
        }
        //查询授权人:找到自己院系的管理员
        private string getAuthoCode(string appCode)
        {
            string  sql       = string.Format(Globalconst.SELECT_CAN_AUTHO, appCode);
            DataSet ds        = CADOConn.GetDataSet(sql);
            string  authoCode = ds.Tables[0].Rows[0][0].ToString();

            return(authoCode);
        }
Ejemplo n.º 4
0
        private void button1_Click(object sender, EventArgs e)
        {
            string objName = textBox_objName.Text;
            string objCode = textBox_ObjCode.Text;

            if (string.IsNullOrEmpty(objName))
            {
                MessageBox.Show("请输入被借阅人姓名!");
                return;
            }
            if (string.IsNullOrEmpty(objCode))
            {
                MessageBox.Show("请输入被借阅人档案号!");
                return;
            }

            //验证姓名和学号是否匹配
            string  sql = string.Format(Globalconst.SELECT_DOCUMENT, objCode);
            DataSet ds  = CADOConn.GetDataSet(sql);

            //如果查询结果为空
            if (ds.Tables[0].Rows.Count == 0)
            {
                MessageBox.Show("查无此人,请检查档案号是否正确!");
                return;
            }
            if (!string.Equals(ds.Tables[0].Rows[0][0].ToString(), objName))
            {
                MessageBox.Show("姓名和档案号不匹配,请重新输入!");
                return;
            }

            //查询此人的档案是否在不在架
            sql = string.Format(Globalconst.SELECT_DOCUMENT_STATUS, objCode);
            ds  = CADOConn.GetDataSet(sql);
            string status = ds.Tables[0].Rows[0][0].ToString();

            if (status == Globalconst.ON_SHELF)
            {
                MessageBox.Show("此人的档案在架,无需归还!");
                return;
            }

            //如果所有条件都符合,就执行归还
            //归还:生成事件,维护档案记录
            //这里最后补充原子性操作
            string data   = System.DateTime.Now.Date.ToString("yyyyMMdd");
            string sqlStr = string.Format(Globalconst.INSERT_EVENT, Globalconst.LEND, objCode, "", Program.curUser.UserName, data);

            CADOConn.ExecuteSQL(sqlStr);

            sqlStr = string.Format(Globalconst.UPDATE_DOCUMENT, Globalconst.ON_SHELF, objCode);
            CADOConn.ExecuteSQL(sqlStr);

            MessageBox.Show("归档成功!");

            this.Close();
        }
Ejemplo n.º 5
0
 //将用户预约表加载到主窗口中
 public void loadDATA()
 {
     try
     {
         //到数据库中查询
         string  sqlStr = string.Format(Globalconst.SELECT_APPLICATION, Program.curUser.IdCode);
         DataSet ds     = CADOConn.GetDataSet(sqlStr);
         dataGridView_application.DataSource = ds.Tables[0];
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
 private void loadData()
 {
     try
     {
         //到数据库中查询
         string  sqlStr = string.Format(Globalconst.SELECT_APPLICATION_ADMIN_ONLY_SHOW_AGREE);
         DataSet ds     = CADOConn.GetDataSet(sqlStr);
         dataGridView_admin.DataSource = ds.Tables[0];
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
        //查询按钮:姓名支持模糊查询
        //当前仅仅支持借档案事件查询
        private void button_query_Click(object sender, EventArgs e)
        {
            string name = "%" + textBox_name.Text.ToString() + "%";
            string code = textBox_code.Text.ToString();
            string sqlStr;

            if (string.IsNullOrEmpty(code))
            {
                sqlStr = string.Format(Globalconst.SELECT_EVENT, name, '%');
            }
            else
            {
                sqlStr = string.Format(Globalconst.SELECT_EVENT, name, code);
            }
            DataSet ds = CADOConn.GetDataSet(sqlStr);

            dataGridView_queryResult.DataSource = ds.Tables[0];
        }
Ejemplo n.º 8
0
        //将数据读取到当前对象中
        public bool GetData(string userName)
        {
            //到数据库中查询
            string sqlStr = string.Format(Globalconst.SELECT_USER, userName);

            try
            {
                DataSet ds = CADOConn.GetDataSet(sqlStr);
                UserName = ds.Tables[0].Rows[0][0].ToString();
                Password = ds.Tables[0].Rows[0][1].ToString();
                IdCode   = ds.Tables[0].Rows[0][2].ToString();
                userType = (UserType)Convert.ToInt32(ds.Tables[0].Rows[0][3].ToString());
                return(true);
            }
            catch (Exception e)
            {
                return(false);
            }
        }
        //载入主窗口时,自动连接数据库
        private void main_Load(object sender, EventArgs e)
        {
            comboBox_userType.SelectedIndex = 0;
            try
            {
                CADOConn.openConn();
            }
            catch (Exception ex)
            {
                MessageBox.Show("数据库连接失败,原因如下:" + ex.Message, "提示");
                Application.Exit();
            }

            //设置提示
            Win32Utility.SetCueText(textBox_user, Globalconst.PLEASE_INPUT_USERNAME);
            Win32Utility.SetCueText(textBox_password, Globalconst.PLEASE_INPUT_PASSWORD);
            //换肤
            skinEngine1.SkinFile = Application.StartupPath + @"/Skins/page.ssk";
        }
        //获得预约号:日期+流水
        private string getAppid()
        {
            //获取系统时间
            string data   = System.DateTime.Now.ToString("yyyyMMdd");
            string sqlStr = string.Format(Globalconst.SELECT_MAX_APPID, data);
            var    temp   = CADOConn.GetDataSet(sqlStr).Tables[0];
            string appid;

            if (temp.Rows[0][0] == DBNull.Value)
            {
                appid = data + "0001";
            }
            else
            {
                appid = temp.Rows[0][0].ToString().Substring(8, 4);
                appid = (Convert.ToInt64(appid) + 1).ToString().PadLeft(4, '0');
                appid = data + appid;
            }
            return(appid);
        }
        //获取数据
        public bool getData(string teeCode)
        {
            //到数据库中查询
            string sqlStr = string.Format(Globalconst.SELECT_APPLICATION, teeCode);

            try
            {
                DataSet ds = CADOConn.GetDataSet(sqlStr);
                AppId     = ds.Tables[0].Rows[0][0].ToString();
                TeeCode   = ds.Tables[0].Rows[0][1].ToString();
                ObjCode   = ds.Tables[0].Rows[0][2].ToString();
                AuthCode  = ds.Tables[0].Rows[0][2].ToString();
                AppStatus = ds.Tables[0].Rows[0][2].ToString();

                return(true);
            }
            catch (Exception e)
            {
                return(false);
            }
        }
Ejemplo n.º 12
0
        //窗口加载时,根据当前登陆用户自动显示我的预约列表
        private void userForm_Load(object sender, EventArgs e)
        {
            //只有院系管理员才有的按钮
            if (Program.curUser.userType == User.UserType.CAN_ANTHORIZE)
            {
                button_lookAuthorizeApp.Visible = true;
            }
            else
            {
                button_lookAuthorizeApp.Visible = false;
            }
            loadDATA();

            //显示当前用户的院系和时间
            label_data.Text = DateTime.Now.Date.ToLongDateString();

            //显示当前用户名
            string  sqlStr = string.Format(Globalconst.SELECT_NAME, Program.curUser.IdCode);
            DataSet ds     = CADOConn.GetDataSet(sqlStr);

            label_userName.Text = "客户端姓名:" + ds.Tables[0].Rows[0][0].ToString();
        }
 public void loadDATA()
 {
     try
     {
         string sqlStr;
         if (!onlyShowPending)
         {
             //到数据库中查询
             sqlStr = string.Format(Globalconst.SELECT_APPLICATION_AUTHO, Program.curUser.IdCode);
         }
         else
         {
             sqlStr = string.Format(Globalconst.SELECT_APPLICATION_AUTHO_ONLY_SHOW_PEND, Program.curUser.IdCode);
         }
         DataSet ds = CADOConn.GetDataSet(sqlStr);
         dataGridView_authorize.DataSource = ds.Tables[0];
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
        private void button_disagree_Click(object sender, EventArgs e)
        {
            if (dataGridView_authorize.CurrentRow == null)
            {
                MessageBox.Show("什么都没选中!");
                return;
            }
            int    selectedRowIndex = dataGridView_authorize.CurrentRow.Index;
            string appId            = dataGridView_authorize.Rows[selectedRowIndex].Cells[0].Value.ToString();
            string appStatus        = dataGridView_authorize.Rows[selectedRowIndex].Cells[4].Value.ToString();

            if (appStatus.Equals(Globalconst.PENDING))
            {
                string sqlStr = string.Format(Globalconst.UPDATE_APPLICATION, Globalconst.DISAGREE, appId);
                CADOConn.ExecuteSQL(sqlStr);
                MessageBox.Show("不同意授权成功!");
                loadDATA();
            }
            else
            {
                MessageBox.Show("该条记录已经处理过!");
            }
        }
        private void button_OK_Click(object sender, EventArgs e)
        {
            string appCode = textBox_applicant.Text;
            string objName = textBox_objname.Text;
            string objCode = textBox_object.Text;

            if (string.IsNullOrEmpty(textBox_objname.Text))
            {
                MessageBox.Show("请输入被借阅人姓名");
                return;
            }
            if (string.IsNullOrEmpty(textBox_object.Text))
            {
                MessageBox.Show("请输入被借阅人姓名");
                return;
            }

            //验证姓名和学号是否匹配
            string  sql = string.Format(Globalconst.SELECT_DOCUMENT, textBox_object.Text);
            DataSet ds  = CADOConn.GetDataSet(sql);

            //如果查询结果为空
            if (ds.Tables[0].Rows.Count == 0)
            {
                MessageBox.Show("查无此人,请检查档案号是否正确!");
                return;
            }
            if (!string.Equals(ds.Tables[0].Rows[0][0].ToString(), textBox_objname.Text))
            {
                MessageBox.Show("姓名和档案号不匹配,请重新输入!");
                return;
            }

            //不能自己借自己的档案
            if (string.Equals(textBox_object.Text, textBox_applicant.Text))
            {
                MessageBox.Show("您没有权限借阅自己的档案!");
                return;
            }

            //如果当前档案不在架,则无法借阅
            sql = string.Format(Globalconst.SELECT_STATUS, objCode);
            ds  = CADOConn.GetDataSet(sql);
            string status = ds.Tables[0].Rows[0][0].ToString();

            if (string.Equals(status, "1"))
            {
                MessageBox.Show("该档案不在架,暂时无法借阅!");
                return;
            }

            //获取预约日期
            string data = dateTimePicker_application.Value.ToString("yyyy-MM-dd");

            //获取授权老师档案号
            string authoCode = getAuthoCode(appCode);
            //获取预约号
            string appId = getAppid();

            //                                                   申请编号       申请人   被借阅人 授权人        日期
            sql = string.Format(Globalconst.INSERT_APPLICATION, appId, appCode, objCode, authoCode, data);
            CADOConn.ExecuteSQL(sql);
            MessageBox.Show("添加成功");
            this.Close();
        }