Esempio 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 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);
        }
Esempio n. 3
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();
        }
Esempio n. 4
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];
        }
Esempio n. 7
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 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);
            }
        }
Esempio n. 10
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_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();
        }