Ejemplo n.º 1
0
 static void Main()
 {
     Model.Reader k = new Model.Reader();
     k.rdID   = 1;
     k.rdName = "马设废";
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     //Application.Run(new admain_frm(k));
     //Application.Run(new borrow_frm(k));
     Application.Run(new login_frm());
 }
Ejemplo n.º 2
0
 //删除操作
 public static int Delete(Reader reader)
 {
     int rows = 0;
     string sql = "delete from Reader where rdID=@rdID";
     SqlParameter[] parameters = { new SqlParameter("@rdID", reader.rdID) };
     try
     {
         rows = SqlHelper.ExecuteNonQuery(sql, parameters);
     }
     catch (SqlException ex)
     {
         throw new Exception(ex.Message);
     }
     return rows;
 }
Ejemplo n.º 3
0
 public Reader(Reader rt)
 {
     this.rdID = rt.rdID;
     this.rdName = rt.rdName;
     this.rdSex = rt.rdSex;
     this.rdType = rt.rdType;
     this.rdDept = rt.rdDept;
     this.rdPhone = rt.rdPhone;
     this.rdEmail = rt.rdEmail;
     this.rdDateReg = rt.rdDateReg;
     this.rdPhoto = rt.rdPhoto;
     this.rdStatus = rt.rdStatus;
     this.rdBorrowQty = rt.rdBorrowQty;
     this.rdPwd = rt.rdPwd;
     this.rdAdminRoles = rt.rdAdminRoles;
 }
Ejemplo n.º 4
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            loginTimes++;
            int rdID;
            rdID = Convert.ToInt32(txtUserID.Text.Trim());
            reader = ReaderAdmin.GetReader(rdID);

            if (reader == null)
            {
                txtUserID.Focus();
                lblReaderInfo.Text = "登录信息:查无此人..{" + loginTimes.ToString() + "}";
            }
            else
            {
                if (reader.rdPwd == txtUserPwd.Text)
                {
                    this.DialogResult = DialogResult.OK;//登录成功
                }
                else
                {
                    txtUserPwd.Text = "";
                    txtUserPwd.Focus();
                    lblReaderInfo.Text = "登录信息:..密码错误!{" + loginTimes.ToString() + "}";
                }
            }

            //使用下面方法会导致数据库注入登录,不安全
            //SqlConnection conn = new SqlConnection("server=.; database=bookLibrary; integrated security=true");
            //conn.Open();
            //SqlCommand cmd = conn.CreateCommand();
            //cmd.CommandText = string.Format("select count(*) from reader where rdid={0} and rdPwd='{1}'", txtUserID.Text, txtUserPwd.Text);
            //int count = Convert.ToInt32(cmd.ExecuteScalar());
            //if (count == 0)
            //{
            //    MessageBox.Show("用户登录失败!");
            //}
            //else
            //{
            //    MessageBox.Show("嘿嘿,登录成功!");
            //}
        }
Ejemplo n.º 5
0
 //修改密码
 public static int UpdatePwd(Reader readerPwd)
 {
     int rows = 0;
     string sql = "update Reader set rdPwd=@rdPwd where rdID=@rdID";
     SqlParameter[] parameters ={
                                    new SqlParameter("@rdID",readerPwd.rdID),
                                    new SqlParameter("@rdPwd",readerPwd.rdPwd)
                               };
     try
     {
         rows = SqlHelper.ExecuteNonQuery(sql, parameters);
     }
     catch (SqlException ex)
     {
         throw new Exception(ex.Message);
     }
     return rows;
 }
Ejemplo n.º 6
0
 public static int Update(Reader reader)
 {
     int rows = 0;
     string sql = "update Reader set "
         + "rdID=@rdID,"
         + "rdName=@rdName,"
         + "rdSex=@rdSex,"
         + "rdType=@rdType,"
         + "rdDept=@rdDept,"
         + "rdPhone=@rdPhone,"
         + "rdEmail=@rdEmail,"
         + "rdDateReg=@rdDateReg,"
         + "rdPhoto=@rdPhoto,"
         + "rdStatus=@rdStatus,"
         + "rdBorrowQty=@rdBorrowQty,"
         + "rdPwd=@rdPwd,"
         + "rdAdminRoles=@rdAdminRoles "
         + "where rdID=@rdID";
     SqlParameter[] parameters ={
                                    new SqlParameter("@rdID",reader.rdID),
                                    new SqlParameter("@rdName",reader.rdName),
                                    new SqlParameter("@rdSex",reader.rdSex),
                                    new SqlParameter("@rdType",reader.rdType),
                                    new SqlParameter("@rdDept",reader.rdDept),
                                    new SqlParameter("@rdPhone",reader.rdPhone),
                                    new SqlParameter("@rdEmail",reader.rdEmail),
                                    new SqlParameter("@rdDateReg",reader.rdDateReg),
                                    new SqlParameter("@rdPhoto",reader.rdPhoto),
                                    new SqlParameter("@rdStatus",reader.rdStatus),
                                    new SqlParameter("@rdBorrowQty",reader.rdBorrowQty),
                                    new SqlParameter("@rdPwd",reader.rdPwd),
                                    new SqlParameter("@rdAdminRoles",reader.rdAdminRoles)
                               };
     try
     {
         rows = SqlHelper.ExecuteNonQuery(sql, parameters);
     }
     catch (SqlException ex)
     {
         throw new Exception(ex.Message);
     }
     return rows;
 }
Ejemplo n.º 7
0
 //借书后更新读者借书本数
 public int UpdateBorrowNum(Reader reader)
 {
     return (BorrowDAL.UpdateBorrowNum(reader));
 }
Ejemplo n.º 8
0
 //选择行操作
 private void dgvReader_SelectionChanged(object sender, EventArgs e)
 {
     if (dgvReader.CurrentCell == null)
         return;
     reader = ReaderAdmin.GetReader((int)dgvReader["rdID", dgvReader.CurrentCell.RowIndex].Value);
     SetReaderToText();
 }
Ejemplo n.º 9
0
 public int Update(Reader reader)
 {
     return (ReaderDAL.Update(reader));
 }
Ejemplo n.º 10
0
 public int UnLoss(Reader reader)
 {
     return (ReaderDAL.UnLoss(reader));
 }
Ejemplo n.º 11
0
 public int Loss(Reader reader)
 {
     return (ReaderDAL.Loss(reader));
 }
Ejemplo n.º 12
0
 public int Insert(Reader reader)
 {
     return (ReaderDAL.Insert(reader));
 }
Ejemplo n.º 13
0
 public int Delete(Reader reader)
 {
     return (ReaderDAL.Delete(reader));
 }
Ejemplo n.º 14
0
        //借书
        private void btnBorrowBook_Click(object sender, EventArgs e)
        {
            int rdID,rdType,bkID;
            int CanLendQty,CanLendDay,rdBorrowQty;
            string rdStatus,bkStatus;
            Borrow borrow = new Borrow();
            Reader reader = new Reader();
            DataRow dr=null;
            DataRow ds = null;

            for(int i=0;i<dgvBook.SelectedRows.Count;i++)
            {
                dr = (dgvBook.SelectedRows[i].DataBoundItem as DataRowView).Row;
            }
            for (int j = 0; j < dgvReader.SelectedRows.Count; j++)
            {
                ds = (dgvReader.SelectedRows[j].DataBoundItem as DataRowView).Row;
            }

            rdID = Convert.ToInt32(txtrdID.Text);
            rdType = Convert.ToInt32(ds.ItemArray[3]);

            dt = borrowBLL.GetReaderType(rdType);
            CanLendQty=Convert.ToInt32(dt.Rows[0][0]);
            CanLendDay = Convert.ToInt32(dt.Rows[0][1]);

            dm = borrowBLL.GetrdStatus(rdID);
            rdStatus = Convert.ToString(dm.Rows[0][0]);
            rdBorrowQty=Convert.ToInt32(dm.Rows[0][1]);

            bkStatus = Convert.ToString(dr.ItemArray[15]);

            if (rdStatus != "有效")
            {
                MessageBox.Show("借书证无效,无法借书,无法借书!");
            }
            else
            {
                if (bkStatus != "在馆")
                {
                    MessageBox.Show("对不起,该书已不在馆!!");
                }
                else
                {
                    if (rdBorrowQty >= CanLendQty)
                    {
                        MessageBox.Show("已借书数超出最大可借书量,无法借书!");
                    }
                    else
                    {
                        borrow.rdID = rdID;
                        borrow.bkID = Convert.ToInt32(dr.ItemArray[0]);
                        borrow.IdContinueTimes = 0;
                        borrow.IdDateOut = DateTime.Now;
                        borrow.IdDateRetPlan = DateTime.Now.AddDays(CanLendDay);
                        borrow.IdDateRetAct = DateTime.Now;
                        borrow.IdOverDay = 0;
                        borrow.IdOverMoney = 0;
                        borrow.IdPunishMoney = 0;
                        borrow.IsHasReturn = false;
                        borrow.OperatorLend = Convert.ToString(ds.ItemArray[1]);
                        borrow.OperatorRet = Convert.ToString(ds.ItemArray[1]);
                        borrowBLL.Insert(borrow);
                        txtbkName.Text = Convert.ToString(borrow.rdID);
                        borrowBLL.UpdateBook(borrow);
                        reader.rdID = rdID;
                        borrowBLL.UpdateBorrowNum(reader);
                        MessageBox.Show("借书成功!!!");
                    }
                }
            }
        }
Ejemplo n.º 15
0
 public static int Insert(Reader reader)
 {
     int rows = 0;
     string sql ="insert into Reader(rdID,rdName,rdSex,rdType,rdDept,rdPhone,rdEmail,rdDateReg,rdPhoto,rdStatus,rdBorrowQty,rdPwd,rdAdminRoles)"
                      +" values (@rdID,@rdName,@rdSex,@rdType,@rdDept,@rdPhone,@rdEmail,@rdDateReg,@rdPhoto,@rdStatus,@rdBorrowQty,@rdPwd,@rdAdminRoles)";
     SqlParameter[] parameters ={
                                    new SqlParameter("@rdID",reader.rdID),
                                    new SqlParameter("@rdName",reader.rdName),
                                    new SqlParameter("@rdSex",reader.rdSex),
                                    new SqlParameter("@rdType",reader.rdType),
                                    new SqlParameter("@rdDept",reader.rdDept),
                                    new SqlParameter("@rdPhone",reader.rdPhone),
                                    new SqlParameter("@rdEmail",reader.rdEmail),
                                    new SqlParameter("@rdDateReg",reader.rdDateReg),
                                    new SqlParameter("@rdPhoto",reader.rdPhoto),
                                    new SqlParameter("@rdStatus",reader.rdStatus),
                                    new SqlParameter("@rdBorrowQty",reader.rdBorrowQty),
                                    new SqlParameter("@rdPwd",reader.rdPwd),
                                    new SqlParameter("@rdAdminRoles",reader.rdAdminRoles)
                               };
     try
     {
         rows = SqlHelper.ExecuteNonQuery(sql, parameters);
     }
     catch (SqlException ex)
     {
         throw new Exception(ex.Message);
     }
     return rows;
 }
Ejemplo n.º 16
0
 //修改密码
 public int UpdatePwd(Reader readerPwd)
 {
     return (ReaderDAL.UpdatePwd(readerPwd));
 }
Ejemplo n.º 17
0
 //借书后更新读者借书本数
 public static int UpdateBorrowNum(Reader reader)
 {
     int rows = 0;
     string sql = "update Reader set rdBorrowQty=rdBorrowQty+1 where rdID=@rdID";
     SqlParameter[] parameters ={
                                    new SqlParameter("@rdID",reader.rdID)
                                };
     try
     {
         rows = SqlHelper.ExecuteNonQuery(sql, parameters);
     }
     catch (SqlException ex)
     {
         throw new Exception(ex.Message);
     }
     return rows;
 }