Пример #1
0
        private void btnEnsure_Click(object sender, EventArgs e)
        {
            AutoId ai = new AutoId();

            if (ValidateInput())
            {
                string   sql;
                DBHelper db = null;
                try
                {
                    db = new DBHelper();
                    string Room_id = cboNewHouse.Text.Substring(0, cboNewHouse.Text.IndexOf(" "));
                    string R_id    = hh.GetR_id(Room_id);
                    sql = string.Format("Update Guest set R_id='{0}',Bookleave='{1}',comeDate='{3}' where G_GuestId='{2}'", R_id, dtpBookLeave.Text, lblOldDate.Tag, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));

                    if (db.UpdateDeleteAdd(sql) > 0)
                    {
                        if (hh.IshaveBook(cboOldHouse.Text))
                        {
                            sql = string.Format("update Room set State ='{0}' where R_id='{1}'", "预订", hh.GetR_id(cboOldHouse.Text));
                        }
                        else
                        {
                            sql = string.Format("update Room set State ='{0}' where R_id='{1}'", "空净", hh.GetR_id(cboOldHouse.Text));
                        }
                        db.UpdateDeleteAdd(sql);

                        sql = string.Format("update Room set State='{0}' where R_id='{1}'", "待客", R_id);
                        db.UpdateDeleteAdd(sql);


                        sql = string.Format("insert into Consume values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}')",
                                            ai.GetId("C_ConsumeId", "Consume"), lblOldDate.Tag, "换房消费", lblOldPrice.Text, 1, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), "房间消费", UserHelper.LoginId, txtRemark.Text
                                            );
                        db.UpdateDeleteAdd(sql);

                        MessageBox.Show("换房成功!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("换房失败!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    db.GetClose();
                }
            }
        }
Пример #2
0
        private void btnascertaintwo_Click(object sender, EventArgs e)
        {
            AutoId dx         = new AutoId();
            string id         = dx.GetId("C_id", "CashManage");
            string admin      = txtxiaban.Text;
            string jiaobanhou = txtxiabanqian.Text;

            sumone = sumone + double.Parse(jiaobanhou);
            string jiaobanqian = "0";
            string jiebandate  = dateTimetwo.Text;

            //在交班表里添加一天下班记录

            string   sqlone = string.Format("insert into CashManage (C_Id,A_AdminId,C_sum,jiaobanhou,jiebanqian,jiebanDate) values('{0}','{1}','{2}','{3}','{4}','{5}')", id, admin, sumone, jiaobanhou, jiaobanqian, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
            DBHelper dr     = new DBHelper();
            int      count  = dr.UpdateDeleteAdd(sqlone);

            if (count > 0)
            {
                MessageBox.Show("下班成功~!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
                IsAwoke.isExit = true;
                Application.Exit();
            }
            else
            {
                MessageBox.Show("下班成功~!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            //关闭数据库
            dr.GetClose();
        }
Пример #3
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (lvCust.SelectedItems.Count <= 0)
            {
                return;
            }
            string       CustId = lvCust.SelectedItems[0].SubItems[0].Text;
            DialogResult result = MessageBox.Show("真的删除?", "删除提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                DBHelper db = null;
                db = new DBHelper();
                try
                {
                    string sql = string.Format("delete Users where U_UsersId ='{0}'", CustId);
                    if (db.UpdateDeleteAdd(sql) > 0)
                    {
                        MessageBox.Show("删除成功!", "删除提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("删除失败!", "删除提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    db.GetClose();
                }
            }
        }
Пример #4
0
        //删除按钮
        private void btnDelete_Click(object sender, EventArgs e)
        {
            string WareName;

            if (lvWare.SelectedItems.Count <= 0)
            {
                return;
            }
            WareName = lvWare.SelectedItems[0].SubItems[0].Text;
            DialogResult result = MessageBox.Show("是否删除?", "删除提示!", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                DBHelper db = null;
                db = new DBHelper();
                string sql  = string.Format("delete Ware where WareName='{0}'", WareName);
                int    rows = db.UpdateDeleteAdd(sql);
                if (rows > 0)
                {
                    MessageBox.Show("删除成功!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("删除失败!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
Пример #5
0
        private void btnUnitFill_Click(object sender, EventArgs e)
        {
            int rowCount = lvUnitFill.SelectedItems.Count;

            DBHelper db = null;

            try
            {
                db = new DBHelper();

                int rows = 0;
                for (int i = 0; i < rowCount; i++)
                {
                    string sql = string.Format("update UnderwriteAnnal set U_money='{0}',shifu='{0}',State='{1}' where A_Id='{2}'", lvUnitFill.Items[i].SubItems[4].Text, "已付", lvUnitFill.Items[i].Tag);
                    MessageBox.Show(sql);
                    rows = db.UpdateDeleteAdd(sql);
                }
                if (rows > 0)
                {
                    MessageBox.Show("操作成功!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("操作失败!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                db.GetClose();
            }
        }
Пример #6
0
        //修改签单
        private void tsbtnDeleteUnderwrite_Click(object sender, EventArgs e)
        {
            if (lvUnderwrite.SelectedItems.Count <= 0)
            {
                return;
            }

            string temp = lvUnderwrite.SelectedItems[0].SubItems[0].Text;

            if (!isHave())
            {
                return;
            }

            DialogResult result = MessageBox.Show("真的删除?", "删除提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                DBHelper db = null;
                try
                {
                    db = new DBHelper();
                    string sql = string.Format("delete Underwrite where U_Id='{0}'", temp);
                    db.UpdateDeleteAdd(sql);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    db.GetClose();
                }
            }
        }
Пример #7
0
        //改整理为空净
        private void ChangeState()
        {
            string   NowTime = DateTime.Now.AddHours(3).ToString("yyyy-MM-dd HH:mm:ss");
            DBHelper db      = null;

            try
            {
                db = new DBHelper();
                string        sql = string.Format("select * from guest left join room on room.R_id=Guest.R_id where state='{0}'", "整理");
                SqlDataReader sdr = db.SelectAll(sql);

                while (sdr.Read())
                {
                    DateTime dt = Convert.ToDateTime(sdr["faceDate"].ToString());
                    if (dt <= Convert.ToDateTime(NowTime))
                    {
                        db  = new DBHelper();
                        sql = string.Format("update room set State = '{0}' where R_id = '{1}' ", "空净", sdr[1].ToString());
                        int rows = db.UpdateDeleteAdd(sql);
                        //MessageBox.Show(sql + rows);
                    }
                }
                sdr.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                db.GetClose();
            }
        }
Пример #8
0
        private void trmRead_Tick(object sender, EventArgs e)
        {
            DBHelper db = null;

            try
            {
                db = new DBHelper();
                string        sql = string.Format("select * from Service where U_UsersId='{0}' and State='{1}' and toId='{2}'", U_UsersId, "未读", UserHelper.LoginId);
                SqlDataReader sdr = db.SelectAll(sql);
                while (sdr.Read())
                {
                    rtbAll.Text = rtbAll.Text + "\n" + sdr["U_UsersId"].ToString() + "  " + sdr["Date"].ToString() + "\n" + sdr["S_content"].ToString();
                    sql         = string.Format("update Service set State='{1}' where U_UsersId ='{0}' and toId='{2}'", U_UsersId, "已读", UserHelper.LoginId);
                    db          = new DBHelper();
                    db.UpdateDeleteAdd(sql);
                }
                sdr.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                db.GetClose();
            }
        }
Пример #9
0
        //删除提醒按钮
        private void tsbtnDeleteAwoke_Click(object sender, EventArgs e)
        {
            if (lvAwoke.SelectedItems.Count <= 0)
            {
                return;
            }
            string       A_AwokeId = lvAwoke.SelectedItems[0].SubItems[0].Text;
            DialogResult result    = MessageBox.Show("是否删除?", "删除提示!", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                DBHelper db = null;
                db = new DBHelper();
                string sql  = string.Format("delete Awoke where A_AwokeId='{0}'", A_AwokeId);
                int    rows = db.UpdateDeleteAdd(sql);
                if (rows > 0)
                {
                    //MessageBox.Show("删除成功!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    lvAwoke.SelectedItems[0].Remove();
                }
                else
                {
                    MessageBox.Show("删除失败!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
Пример #10
0
        private void lvFitoutHouse_DoubleClick(object sender, EventArgs e)
        {
            //双击以预定的房间 跳到要预定的房间   并将数据库改变

            ListViewItem list    = this.lvFitoutHouse.SelectedItems[0];
            string       listone = list.SubItems[0].Text;
            string       bookid  = list.Tag.ToString();
            string       sql     = string.Format("update room set state='预订' where R_RoomId='{0}'", listone);
            string       sqlone  = string.Format("update book set state='预订' where b_bookid='{0}'", bookid);

            DBHelper dx = new DBHelper();

            dx.UpdateDeleteAdd(sql);

            //关闭数据库
            dx.GetClose();
            DBHelper dr = new DBHelper();

            dr.UpdateDeleteAdd(sqlone);

            //关闭数据库
            dr.GetClose();
            this.lvFitoutHouse.Items.Remove(list);
            this.lvBookHouse.Items.Add(list);
        }
Пример #11
0
        private void btnSend_Click(object sender, EventArgs e)
        {
            DBHelper db = null;

            try
            {
                AutoId ai = new AutoId();
                rtbAll.Text = rtbAll.Text + "\n" + UserHelper.LoginId + "  " + DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "\n" + rtbSelf.Text;

                db = new DBHelper();
                string sql = string.Format("insert into Service values('{0}','{1}','{2}','{3}','{4}','{5}')",
                                           ai.GetId("S_serviceId", "Service"), U_UsersId, UserHelper.LoginId, rtbSelf.Text, "未读", DateTime.Now.ToString("yyyy-MM-dd HH:mm")
                                           );
                //MessageBox.Show(sql);
                if (db.UpdateDeleteAdd(sql) <= 0)
                {
                    MessageBox.Show("发送失败!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    rtbSelf.Text = "";
                }
                rtbSelf.Focus();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                db.GetClose();
            }
        }
Пример #12
0
        //改为可供
        private void tsmiKG_Click(object sender, EventArgs e)
        {
            DBHelper db = null;

            try
            {
                db = new DBHelper();
                if (lvConsole.SelectedItems.Count <= 0)
                {
                    return;
                }
                string state = ((ToolStripMenuItem)sender).Text;

                string roomId = lvConsole.SelectedItems[0].SubItems[0].Text;
                string sql    = string.Format("update Room set State ='{0}' where R_RoomId='{1}'", state, roomId);
                //MessageBox.Show(sql);
                if (db.UpdateDeleteAdd(sql) > 0)
                {
                    MessageBox.Show("修改成功!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("修改失败!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                db.GetClose();
            }
        }
Пример #13
0
        //保存按钮
        private void btnSave_Click(object sender, EventArgs e)
        {
            DBHelper db = null;

            try
            {
                db = new DBHelper();
                string sql = string.Format("update purview set Ispurview = '{0}',SysSet = '{1}',HAdd = '{2}',HUpdate = '{3}',HDelete = '{4}',EAdd = '{5}',EUpdate = '{6}',EDelete = '{7}',AAdd = '{8}',AUpdate = '{9}',ADelete = '{10}',UAdd = '{11}',UUpdate = '{12}',UDelete = '{13}',LLook = '{14}',LDelete = '{15}' ,Qiantai = '{16}',Yuding = '{17}',ShouYin = '{18}',jiben = '{19}' where Admin='{20}' ",
                                           (chkIspurview.Checked == true) ? 1 : 0,
                                           (chkSysSet.Checked == true) ? 1 : 0,

                                           (chkHAdd.Checked == true) ? 1 : 0,
                                           (chkHUpdate.Checked == true) ? 1 : 0,
                                           (chkHDelete.Checked == true) ? 1 : 0,

                                           (chkEAdd.Checked == true) ? 1 : 0,
                                           (chkEUpdate.Checked == true) ? 1 : 0,
                                           (chkEDelete.Checked == true) ? 1 : 0,

                                           (chkAAdd.Checked == true) ? 1 : 0,
                                           (chkAUpdate.Checked == true) ? 1 : 0,
                                           (chkADelete.Checked == true) ? 1 : 0,

                                           (chkUAdd.Checked == true) ? 1 : 0,
                                           (chkUUpdate.Checked == true) ? 1 : 0,
                                           (chkUDelete.Checked == true) ? 1 : 0,

                                           (chkLLook.Checked == true) ? 1 : 0,
                                           (chkLDelete.Checked == true) ? 1 : 0,

                                           (chkQiantai.Checked == true) ? 1 : 0,
                                           (chkYuding.Checked == true) ? 1 : 0,
                                           (chkShouYin.Checked == true) ? 1 : 0,
                                           (chkBaseOper.Checked == true) ? 1 : 0,
                                           AdminId
                                           );
                if (db.UpdateDeleteAdd(sql) > 0)
                {
                    MessageBox.Show("保存成功!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
                else
                {
                    MessageBox.Show("保存失败!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                db.GetClose();
            }
        }
Пример #14
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (cboGuest.Text == "")
            {
                MessageBox.Show("客房不能为空", " 温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                cboGuest.Focus();
                return;
            }
            else if (cboUnite.Text == "")
            {
                MessageBox.Show("并入客房不能为空", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                cboUnite.Focus();
                return;
            }
            string uName           = "";
            string sex             = "";
            string CertificateType = "";
            string CertificateID   = "";
            string CertificatePic  = "";
            string Address         = "";
            string contactTel      = "";

            DBHelper db = null;

            db = new DBHelper();
            string sql = string.Format("select * from Guest where G_GuestId='{0}'", guestIdTwo);

            SqlDataReader sdr = db.SelectAll(sql);

            if (sdr.Read())
            {
                uName           = sdr["Uname"].ToString();
                sex             = sdr["Sex"].ToString();
                CertificateType = sdr["CertificateType"].ToString();
                CertificateID   = sdr["CertificateID"].ToString();
                CertificatePic  = sdr["CertificatePic"].ToString();
                Address         = sdr["Address"].ToString();
                contactTel      = sdr["contactTel"].ToString();
            }
            sdr.Close();

            sql = string.Format("update Guest set Uname='{0}',sex='{1}',CertificateType='{2}',CertificateID='{3}',CertificatePic='{4}',Address='{5}',contactTel='{6}' where G_GuestId='{7}'",
                                uName, sex, CertificateType, CertificateID, CertificatePic, Address, contactTel, guestIdOne
                                );
            if (db.UpdateDeleteAdd(sql) > 0)
            {
                MessageBox.Show("联房成功!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
            }
            else
            {
                MessageBox.Show("联房失败!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Пример #15
0
        //ok按钮
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (lblroom.Text == "")
            {
                MessageBox.Show("没选定房间!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                DialogResult result;

                string   sql;
                string   message;
                DBHelper db = null;
                try
                {
                    db = new DBHelper();
                    if (isCheck)
                    {
                        sql     = string.Format("update Guest set AdvanceForegift = AdvanceForegift + '{0}' where R_id='{1}' and  faceDate ='{2}'", txtDeposit.Text, lblroom.Tag, "");
                        message = string.Format("{0}房\n交押金{1}", lblroom.Text, txtDeposit.Text);
                    }
                    else
                    {
                        sql     = string.Format("update Guest set AdvanceForegift = AdvanceForegift - '{0}' where R_id='{1}' and  faceDate ='{2}'", txtDeposit.Text, lblroom.Tag, "");
                        message = string.Format("{0}房\n退押金{1}", lblroom.Text, txtDeposit.Text);
                    }

                    result = MessageBox.Show(message, "确定", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (result == DialogResult.No)
                    {
                        return;
                    }
                    int rows = db.UpdateDeleteAdd(sql);
                    if (rows > 0)
                    {
                        MessageBox.Show("修改成功!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("修改失败!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    db.GetClose();
                }
            }
        }
Пример #16
0
        //写入商品消费表中
        private void Consume()
        {
            string      G_GuestId = "";
            AutoId      ai        = new AutoId();      //自动生成id  辅助类
            HouseHelper hh        = new HouseHelper(); //辅助类
            DBHelper    db        = null;              //连数据库类

            db = new DBHelper();
            try
            {
                string sql;
                string C_ConsumeId;
                string R_id = hh.GetR_id(cboRoomId.Text);

                sql = string.Format("select G_GuestId from Guest where R_id='{0}' and faceDate='{1}'", R_id, "");
                SqlDataReader sdr = db.SelectAll(sql);
                if (sdr.Read())
                {
                    G_GuestId = sdr["G_GuestId"].ToString();
                }
                sdr.Close();
                int rows = 0;
                //循环写入
                for (int i = 0; i < lvSelect.Items.Count; i++)
                {
                    C_ConsumeId = ai.GetId("C_ConsumeId", "Consume");
                    sql         = string.Format("insert into Consume values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}')",
                                                C_ConsumeId, G_GuestId, lvSelect.Items[i].SubItems[0].Text, lvSelect.Items[i].SubItems[2].Text, lvSelect.Items[i].SubItems[3].Text,
                                                DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), "商品消费", UserHelper.LoginId, "");
                    //MessageBox.Show(sql);
                    rows = db.UpdateDeleteAdd(sql);
                }

                if (rows > 0)
                {
                    MessageBox.Show("消费成功!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("消费失败!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                db.GetClose();
            }
        }
Пример #17
0
        private void AwokeFrom_FormClosing(object sender, FormClosingEventArgs e)
        {
            DBHelper db = null;

            db = new DBHelper();
            string A_AwokeId;

            for (int i = 0; i < lvAwoke.Items.Count; i++)
            {
                A_AwokeId = lvAwoke.Items[i].Tag.ToString();
                string sql  = string.Format("Update Awoke set State='{0}' where A_AwokeId='{1}'", "已读", A_AwokeId);
                int    rows = db.UpdateDeleteAdd(sql);
            }
        }
Пример #18
0
        //删除日志
        private void tsbtnDeleteLoginLog_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < lvLoginLog.SelectedItems.Count; i++)
            {
                string   temp = lvLoginLog.SelectedItems[i].SubItems[0].Text;
                DBHelper db   = new DBHelper();
                db = new DBHelper();
                string sql  = string.Format("delete LoginLog where L_LoginLogId='{0}'", temp);
                int    rows = (db.UpdateDeleteAdd(sql));
                //MessageBox.Show(rows.ToString());
            }

            //重新显示日志
            ShowL_LoginLogId();
        }
Пример #19
0
        private void lvSelectHouse_DoubleClick(object sender, EventArgs e)
        {
            //双击已预定的房间中的listview 跳到未预定的listview  并将数据库更改
            ListViewItem list    = this.lvSelectHouse.SelectedItems[0];
            string       listone = list.SubItems[0].Text;
            string       sql     = string.Format("update room set state='空净' where r_roomid='{0}' ", listone);
            DBHelper     dx      = new DBHelper();

            dx.UpdateDeleteAdd(sql);

            //关闭数据库
            dx.GetClose();
            this.lvSelectHouse.Items.Remove(list);
            lvHollowHouse.Items.Add(list);
        }
Пример #20
0
        ////自动解除预订
        private void RescindBook()
        {
            DBHelper db = null;

            try
            {
                db = new DBHelper();
                string        sql = string.Format("select * from Book");
                SqlDataReader sdr = db.SelectAll(sql);
                while (sdr.Read())
                {
                    if (Convert.ToDateTime(sdr["comeDate"]) < Convert.ToDateTime(DateTime.Now.AddHours(IsAwoke.ExceedTime).ToString("yyyy-MM-dd HH:mm:ss")) && sdr["State"].ToString() == "预订")
                    {
                        //MessageBox.Show(Convert.ToDateTime(DateTime.Now.AddHours(5).ToString("yyyy-MM-dd HH:mm:ss")).ToString()+"   "+sdr["comeDate"].ToString());

                        db  = new DBHelper();
                        sql = string.Format("update Book set State = '已解除' where B_BookId = '{0}'", sdr["B_BookId"]);
                        // MessageBox.Show(sql);
                        int rows = (int)db.UpdateDeleteAdd(sql);
                        //MessageBox.Show(rows.ToString());
                        sql = string.Format("update Room set State = '空净' where R_RoomId = '{0}'", sdr["Room_id"]);
                        // MessageBox.Show(sql);
                        db.UpdateDeleteAdd(sql);
                    }
                }
                sdr.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                db.GetClose();
            }
        }
Пример #21
0
        //写入数据库方法
        private void InsertCust()
        {
            DBHelper db = null;

            try
            {
                db = new DBHelper();
                string sql = "";

                string sex;
                if (rdoMan.Checked)
                {
                    sex = "男";
                }
                else
                {
                    sex = "女";
                }

                if (type == 0)
                {
                    sql = string.Format("insert into Users values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}')",
                                        TxtID.Text, Txtname.Text, Txtpwd.Text, 0, cboPaper.Text, TxtpaperID.Text, txtAddress.Text, sex, TxtcontactTel.Text, 0, txtRemark.Text
                                        );
                }
                else
                {
                    sql = string.Format("update Users set Uname = '{0}',Pass = '******',CertificateType ='{2}',CertificateID = '{3}',Address = '{4}',Usex = '{5}',contactTel= '{6}',remark = '{7}' where U_UsersId='{8}'",
                                        Txtname.Text, Txtpwd.Text, cboPaper.Text, TxtpaperID.Text, txtAddress.Text, sex, TxtcontactTel.Text, txtRemark.Text, TxtID.Text
                                        );
                }

                if (db.UpdateDeleteAdd(sql) > 0)
                {
                    MessageBox.Show("操作成功!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
                else
                {
                    MessageBox.Show("操作失败!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #22
0
        //添加事件
        private void btnAdd_Click(object sender, EventArgs e)
        {
            //验证是否为空
            if (ValidateInput())
            {
                DBHelper db = null;
                db = new DBHelper();
                string sql = string.Format("select count(R_RoomId) from Room where R_RoomId='{0}'", txtRoom_id.Text);
                if (db.UpdateDeleteAdd(sql) > 0)
                {
                    MessageBox.Show("已经存在相同的房间号,请另选!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                AddHouse();
            }
        }
Пример #23
0
        private void Underwrite()
        {
            AutoId   ai = new AutoId();
            DBHelper db = null;
            string   sql;

            try
            {
                db = new DBHelper();
                if (type == 0)
                {
                    sql = string.Format("insert into Underwrite values('{0}','{1}','{2}')",
                                        ai.GetId("U_Id", "Underwrite"), txtUnderwrite.Text, txtRemark.Text);
                }
                else
                {
                    sql = string.Format("update Underwrite set Underwrite='{0}',Remark='{1}' where U_Id='{2}'", txtUnderwrite.Text, txtRemark.Text, listStr[0]);
                }
                if (db.UpdateDeleteAdd(sql) > 0)
                {
                    if (chkBatch.Checked)
                    {
                        txtUnderwrite.Text = "";
                        txtRemark.Text     = "";
                        txtUnderwrite.Focus();
                    }
                    else
                    {
                        MessageBox.Show("操作成功!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.Close();
                    }
                }
                else
                {
                    MessageBox.Show("添操作失败!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                db.GetClose();
            }
        }
Пример #24
0
        //添加操作
        private void AddHouse()
        {
            DBHelper db  = null;
            string   sql = "";

            try
            {
                db = new DBHelper();

                //根据type来判断是添加操作,还是修改操作
                if (type == "")
                {
                    sql = string.Format("insert into room values('{0}','{1}','{2}','{3}','{4}','{5}','{6}')",
                                        txtRoom_id.Text, "空净", txtFloot.Text, (cboRoomType.SelectedIndex + 1), txtPrice.Text, 0, txtfixing.Text
                                        );
                }
                else
                {
                    sql = string.Format("update room set R_RoomId='{0}',State='{1}',Floot='{2}',RoomType='{3}',price='{4}',R_Count='{5}',fixing='{6}' where R_RoomId='{7}'",
                                        txtRoom_id.Text, "空净", txtFloot.Text, (cboRoomType.SelectedIndex + 1), txtPrice.Text, 0, txtfixing.Text, type
                                        );
                }



                if (db.UpdateDeleteAdd(sql) > 0)
                {
                    MessageBox.Show("操作成功!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
                else
                {
                    MessageBox.Show("操作失败!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                db.GetClose();
            }
        }
Пример #25
0
        //添加方法
        private void AddHouse()
        {
            DBHelper db  = null;
            string   sql = "";

            try
            {
                db = new DBHelper();

                //根据传值,来判断是插入操作,还是修改操作
                if (type == "")
                {
                    sql = string.Format("insert into Admin values('{0}','{1}','{2}','{3}')",
                                        txtA_AdminId.Text, txtName.Text, txtPass.Text, cboType.Text
                                        );
                }
                else
                {
                    sql = string.Format("update Admin set A_AdminId='{0}',A_Name='{1}',Password='******',A_Type='{3}' where A_AdminId='{4}'",
                                        txtA_AdminId.Text, txtName.Text, txtPass.Text, cboType.Text, type
                                        );
                }



                if (db.UpdateDeleteAdd(sql) > 0)
                {
                    MessageBox.Show("操作成功!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
                else
                {
                    MessageBox.Show("操作失败!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                db.GetClose();
            }
        }
Пример #26
0
        //添加提醒
        private void AddAwoke()
        {
            AutoId   ai        = new AutoId();
            string   A_AwokeId = ai.GetId("A_AwokeId", "Awoke");
            DBHelper db        = null;
            string   sql;

            try
            {
                //MessageBox.Show(dtpDate.Text);
                db = new DBHelper();
                //如果是0,则是添加语句  //否则是修改
                if (type == 0)
                {
                    sql = string.Format("insert into Awoke values('{0}','{1}','{2}','{3}','{4}')",
                                        A_AwokeId, txtA_content.Text, cboState.Text, dtpDate.Text, txtRemark.Text
                                        );
                }
                else
                {
                    sql = string.Format("update Awoke set A_content='{0}',State='{1}',Date='{2}',Remark='{3}' where A_AwokeId='{4}'",
                                        txtA_content.Text, cboState.Text, dtpDate.Text, txtRemark.Text, listString[0]
                                        );
                }

                if (db.UpdateDeleteAdd(sql) > 0)
                {
                    MessageBox.Show("操作成功!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
                else
                {
                    MessageBox.Show("操作失败!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                db.GetClose();
            }
        }
Пример #27
0
        //ok按钮
        private void btnOk_Click(object sender, EventArgs e)
        {
            //验证输入是否为空
            if (!ValidateInput())
            {
                return;
            }

            //验证总和当中是否有这么多金额
            if (!haveMoney())
            {
                MessageBox.Show("金额小于支出", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            AutoId ai = new AutoId();

            DBHelper db = null;

            try
            {
                db = new DBHelper();
                string sql = string.Format("insert into defray values('{0}','{1}','{2}','{3}','{4}','{5}')", ai.GetId("D_defrayId", "defray"), (0 - Math.Abs(Convert.ToDouble(txtPrice.Text))), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), txtC_type.Text, UserHelper.LoginId, "");
                //MessageBox.Show(sql);
                int rows = db.UpdateDeleteAdd(sql);
                if (rows > 0)
                {
                    MessageBox.Show("支出成功!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
                else
                {
                    MessageBox.Show("支出失败!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                db.GetClose();
            }
        }
Пример #28
0
        //删除员工
        private void tsBtnDeleteCust_Click(object sender, EventArgs e)
        {
            if (lvAdmin.SelectedItems.Count <= 0)
            {
                return;
            }
            //如果正是使用,则不能删除
            if (lvAdmin.SelectedItems[0].Text == UserHelper.LoginId)
            {
                MessageBox.Show("此服务员正在使用中...", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            string       A_AdminId = lvAdmin.SelectedItems[0].SubItems[0].Text;
            DialogResult result    = MessageBox.Show("是否删除" + A_AdminId, "删除提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                DBHelper db = null;
                try
                {
                    db = new DBHelper();
                    string sql = string.Format("delete Admin where A_AdminId='{0}'", A_AdminId);
                    if (db.UpdateDeleteAdd(sql) > 0)
                    {
                        //MessageBox.Show("删除成功!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("删除失败!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    db.GetClose();
                    ShowEmp();
                }
            }
        }
Пример #29
0
        //删除房子按钮
        private void tsbtnDeleteHouse_Click(object sender, EventArgs e)
        {
            if (lvHouse.SelectedItems.Count <= 0)
            {
                return;
            }
            if (lvHouse.SelectedItems[0].SubItems[1].Text != "空净")
            {
                MessageBox.Show("此房间状态为非空净!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            string       Room_id = lvHouse.SelectedItems[0].SubItems[0].Text;
            DialogResult result  = MessageBox.Show("是否删除" + Room_id, "删除提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                DBHelper db = null;
                try
                {
                    db = new DBHelper();
                    string sql = string.Format("delete Room where R_RoomId='{0}'", Room_id);
                    if (db.UpdateDeleteAdd(sql) > 0)
                    {
                        //MessageBox.Show("删除成功!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("删除失败!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    db.GetClose();
                    ShowHouse("0");
                }
            }
        }
Пример #30
0
        //记录日志
        private void AnnalLog()
        {
            DBHelper db = null;

            try
            {
                db = new DBHelper();

                string sql = string.Format("update LoginLog set LeaveDate='{0}' where L_LoginLogId='{1}'", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), UserHelper.L_LoginLogId);
                db.UpdateDeleteAdd(sql);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                db.GetClose();
            }
        }