Ejemplo n.º 1
0
        public bool checkLogin(string sta_id, string password)
        {
            sta_id   = sta_id.Trim();
            password = password.Trim();
            ControlAccess ctrl    = new ControlAccess();
            string        sqlStr1 = "select count(sta_id) from STAFF where sta_id='" + sta_id + "'";

            if (Convert.ToInt32(ctrl.ExecuteScalar(sqlStr1)) <= 0)
            {
                System.Windows.Forms.MessageBox.Show("没有这个账号,请重新输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(false);
            }
            string sqlStr2 = string.Format("select count(*) from STAFF where sta_id='{0}'and sta_password='******' ", sta_id, password);

            if (Convert.ToInt32(ctrl.ExecuteScalar(sqlStr2)) == 1)
            {
                string sql = string.Format("select po_title from STAFF where sta_id='{0}'", sta_id);
                position = Convert.ToString(ctrl.ExecuteScalar(sql));
                string sql1 = string.Format("select sta_name from STAFF where sta_id='{0}'", sta_id);
                name = Convert.ToString(ctrl.ExecuteScalar(sql1));
                return(true);
            }
            else
            {
                System.Windows.Forms.MessageBox.Show("密码不对,请重新输入密码!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(false);
            }
        }
Ejemplo n.º 2
0
        public void sell(int amount)
        {
            string sql1 = "select b_amount from Book where b_isbn='" + book_id + "'";
            string sql2 = "select b_sell_price from Book where b_isbn='" + book_id + "'";

            left_amount = Convert.ToInt32(dbutil.ExecuteScalar(sql1));
            money       = (float)(Convert.ToDouble(dbutil.ExecuteScalar(sql2)));
            sell_amount = amount;
        }
Ejemplo n.º 3
0
        //创建账户
        //员工ID需要在数据库中设置主键为自动生成
        //需要用到的参数是员工的姓名,等级,地址,出生日期,电话号码,职位,密码,

        public bool  createUser(string sta_name,
                                string sta_gender,
                                string sta_address,
                                string sta_birth,
                                string sta_tele,
                                string po_title,
                                string sta_password)
        {
            ControlAccess ctrl = new ControlAccess();

            System.DateTime currentTime = new System.DateTime();
            string          strYMD      = currentTime.ToString("d"); //生成入职时间


            string strmax = "select max(sta_id) from STAFF";
            int    a      = 1;
            int    number = Convert.ToInt32(ctrl.ExecuteScalar(strmax));

            msta_id = Convert.ToString(number + 1);       //生成员工编号

            Staff sta = new Staff();

            sta.Sta_id        = msta_id;
            sta.Sta_name      = sta_name;
            sta.Sta_gender    = sta_gender;
            sta.Sta_address   = sta_address;
            sta.Sta_birth     = sta_birth;
            sta.Sta_tele      = sta_tele;
            sta.Po_title      = po_title;
            sta.Sta_password  = sta_password;
            sta.Sta_sign_date = strYMD;



            try
            {
                string sqlstr = "insert into STAFF values('" + sta.Sta_id + "'" + "," + "'" + sta.Sta_name + "'" + "," + "'" + sta.Sta_gender + "'" + "," + "'" + sta.Sta_address + "'" + "," + "to_date('" + sta.Sta_birth + "'" + "," + "'" + "yyyy-mm-dd" + "'" + ")" + "," + "'" + sta.Sta_tele + "'" + "," + "to_date('" + sta.Sta_birth + "'" + "," + "'" + "yyyy-mm-dd" + "'" + ")" + "," + "'" + sta.Po_title + "'" + "," + "'" + sta.Sta_password + "'" + "," + "'" + "yes" + "'" + ")";
                Console.WriteLine(sqlstr);
                ctrl.ExecuteScalar(sqlstr);
            }
            catch (Exception ex)
            {
                ctrl.Close();
                return(false);
            }
            finally
            {
                ctrl.Close();
            }
            return(true);
        }
Ejemplo n.º 4
0
        //得到预订订单号
        public void getreserve_number()
        {
            string sql  = "select max(rev_id) from ReserveRecord";
            string sql1 = "select count(*) from ReserveRecord";
            long   reserve_id;

            if (Convert.ToInt32(dbutil.ExecuteScalar(sql1)) == 0)
            {
                reserve_id = 4001;
            }
            else
            {
                reserve_id = Convert.ToInt64(dbutil.ExecuteScalar(sql)) + 1;
            }
            reserve_number = Convert.ToString(reserve_id);
        }
Ejemplo n.º 5
0
        public void gettrade_number()
        {
            string sql  = "select max(tra_id) from TradeRecord";
            string sql1 = "select count(*) from TradeRecord";
            long   trade_id;

            if (Convert.ToInt32(dbutil.ExecuteScalar(sql1)) == 0)
            {
                trade_id = 5001;
            }
            else
            {
                trade_id = Convert.ToInt64(dbutil.ExecuteScalar(sql)) + 1;
            }
            trade_number = Convert.ToString(trade_id);
        }
Ejemplo n.º 6
0
        public String findName(string sta_id)
        {
            ControlAccess ctrl     = new ControlAccess();
            string        str      = String.Format("select sta_name from STAFF where sta_id='{0]'", sta_id);
            string        sta_name = Convert.ToString(ctrl.ExecuteScalar(str));

            return(sta_name);
        }
Ejemplo n.º 7
0
        //生成一条操作ID
        public string NewManageId()
        {
            string sql1 = "select max(mag_num) from (select to_number(mag_id) mag_num from ManageRecord)";
            int    max_num;

            int.TryParse(ctrl.ExecuteScalar(sql1).ToString(), out max_num);
            string manage_id = Convert.ToString(max_num + 1);

            return(manage_id);
        }
Ejemplo n.º 8
0
        //员工每月的月薪的计算
        //迟到早退扣20,缺勤扣100,请假扣80
        //需要输入员工的ID,年,月
        //结果返回int型的salary
        public void salaryPerMonth(string ms_year, string ms_month)
        {
            int ms_year1  = Convert.ToInt32(ms_year);
            int ms_month1 = Convert.ToInt32(ms_month);

            int           salary = 0;
            ControlAccess ctrl   = new ControlAccess();

            try
            {
                //System.DateTime currentTime = new System.DateTime();
                // string strYMD = currentTime.ToString("d");
                string           sqlid = "select sta_id from staff where sta_on_job='yes'";
                OracleDataReader odr   = ctrl.ExecuteReader(sqlid);
                if (odr.HasRows)
                {
                    while (odr.Read())
                    {
                        string sta_id = Convert.ToString(odr[0]);
                        string sqlsal = string.Format("select po_salary from POSITION natural join STAFF  where  STAFF.sta_id='{0}'", sta_id);
                        string sqlday = string.Format("select ms_absent,ms_lea_early,ms_late,ms_leave from MONTHSTATISTICS where sta_id='{0}' and ms_year='{1}' and ms_month='{2}'", sta_id, ms_year1, ms_month1);


                        DataSet set = ctrl.GetDataSet(sqlday);
                        salary = Convert.ToInt32(ctrl.ExecuteScalar(sqlsal)) - Convert.ToInt32(set.Tables[0].Rows[0][0]) * 100 - (Convert.ToInt32(set.Tables[0].Rows[0][1]) + Convert.ToInt32(set.Tables[0].Rows[0][2])) * 20 - Convert.ToInt32(set.Tables[0].Rows[0][3]) * 80;
                        string sqlupdate = string.Format("update MONTHSTATISTICS set ms_salary='{0}'", salary);
                        ctrl.ExecuteScalar(sqlupdate);
                    }
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                ctrl.Close();
            }
        }
Ejemplo n.º 9
0
        //店长修改员工的职位
        //需要传入员工的ID和被修改为 的职位
        public bool changePower(string sta_id, string po_title)
        {
            ControlAccess ctrl = new ControlAccess();

            try
            {
                string sqlstr = string.Format("update STAFF set po_title='{0}' where sta_id='{1}'", po_title, sta_id);
                //  ctrl.Open();
                ctrl.ExecuteScalar(sqlstr);
            }
            catch (Exception ex)
            {
                return(false);
            }
            finally
            {
                ctrl.Close();
            }
            return(true);
        }
Ejemplo n.º 10
0
        /***************************
        * 以下是会员注册相关函数
        ***************************/
        public string getNextID()  //根据会员表里maxID生成新的会员号
        {
            int    maxID;
            string sql = "select max(mem_id) from Member";

            maxID = Convert.ToInt32(dbutil.ExecuteScalar(sql));
            return(Convert.ToString(maxID + 1));
        }