Exemplo n.º 1
0
        public bool AddMemeberAction(string Name, int Age, string Sex, string Briday)
        {
            string NowTime             = DateTime.Now.ToString("yyyy/MM/dd");
            string InsertIntoSqlString = $"insert into MemeberInfo values('{Name}',{Age},'{Sex}','{NowTime}','{NowTime}','{Briday}')";
            bool   MemeberExits        = IsExitsMemeber(Name);

            if (MemeberExits == false)
            {
                SqlConnection Oss        = new OpenSQLSERVER().Start();
                int           WriteState = new CreateSQLCommand().ExcuteSqlStr(Oss, InsertIntoSqlString);
                if (WriteState != 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                new ShowMessageBox().ShowInforMation("暂时无法修改已有会员数据,请等待下一版本更新", "提示");
                return(false);
            }
        }
Exemplo n.º 2
0
 public DataTable QueryData()
 {
     try
     {
         SqlConnection SQlConRsul = null;
         OpenSQLSERVER OSL        = new OpenSQLSERVER();
         SQlConRsul = OSL.Start();
         string         SQLstring = "select * from MemeberInfo";
         SqlDataAdapter SDA       = new SqlDataAdapter(SQLstring, SQlConRsul);
         DataSet        DST       = new DataSet();
         SDA.Fill(DST);
         string    a           = DST.Tables[0].Rows[0].ToString();
         DataTable ReturnTable = DST.Tables[0];
         SQlConRsul.Close();
         //OSL.Close();
         return(ReturnTable);
     }
     catch (Exception ERROR)
     {
         ShowMessageBox SMB = new ShowMessageBox();
         SMB.ShowError("发生错误,请检查数据库连接", "错误");
         WriteLog W = new WriteLog();
         W.WriteToLogFile(ERROR.Message);
         return(null);
     }
 }
Exemplo n.º 3
0
        public void AddMemberRecord(string Name)
        {
            bool state = CheckMember(Name);

            if (state)
            {
                string        NowTime    = DateTime.Now.ToString("yyyy/MM/dd");
                string        UpdateStr  = $"update MemeberInfo set FirstTime_Come='{NowTime}',LeaveTime='{NowTime}' where Name='{Name}'";
                SqlConnection Oss        = new OpenSQLSERVER().Start();
                int           ReturnCode = new CreateSQLCommand().ExcuteSqlStr(Oss, UpdateStr);
                if (ReturnCode != 0)
                {
                    new ShowMessageBox().ShowInforMation("已记录会员来访", "提示");
                    new WriteLog().WriteToLogFile($"会员来访:会员名称:{Name}");
                }
                else
                {
                    new ShowMessageBox().ShowError("记录出错,可能和服务器短裤连接", "错误");
                }
            }
            else
            {
                new ShowMessageBox().ShowError("没有找到会员,请确认后重试", "错误");
            }
        }
        private void Login_Form_LoginButton_Click(object sender, EventArgs e)
        {
            ShowMessageBox SMB = new ShowMessageBox();

            try
            {
                if (Login_Form_UserName.Text.Trim() == "" && Login_Form_UserPassword.Text.Trim() == "")
                {
                    SMB.ShowError("请输入账号密码", "错误");
                }
                else
                {
                    SqlConnection LoginConnectResult = null;
                    OpenSQLSERVER OSS = new OpenSQLSERVER();
                    LoginConnectResult = OSS.Start();
                    SqlCommand SQLCMD = LoginConnectResult.CreateCommand();
                    SQLCMD.CommandType = CommandType.Text;
                    SQLCMD.CommandText = $"select UserName from Super_Info";
                    SqlDataReader UnameRead = SQLCMD.ExecuteReader();
                    if (UnameRead.Read())
                    {
                        string ReaderUserName = UnameRead["UserName"].ToString();
                        if (ReaderUserName == Login_Form_UserName.Text.Trim())
                        {
                            UnameRead.Close();
                            SQLCMD.CommandText = "select PassWord from Super_Info";
                            SqlDataReader PassWordRead = SQLCMD.ExecuteReader();
                            if (PassWordRead.Read())
                            {
                                string ReaderPassWord = PassWordRead["PassWord"].ToString();
                                if (ReaderPassWord == Login_Form_UserPassword.Text.Trim())
                                {
                                    SMB.ShowInforMation("登录成功", "提示");
                                    PassWordRead.Close();
                                    LoginConnectResult.Close();
                                    Hide();
                                    MemberInfoForm MIF = new MemberInfoForm();
                                    MIF.Show();
                                }
                                else
                                {
                                    SMB.ShowError("密码错误,请重新登录", "错误");
                                }
                            }
                        }
                        else
                        {
                            SMB.ShowError("账号错误,请重新登录", "错误");
                        }
                    }
                }
            }
            catch (Exception ErrorMessage)
            {
                WriteLog WLG = new WriteLog();
                WLG.WriteToLogFile(ErrorMessage.Message);
                SMB.ShowError("数据库连接失败,可能是以下原因:\n1.数据库的账号密码没有设为sa/123456\n2.数据库端口没有启动\n3.数据库服务没有启动\n4.其他异常问题\n请检查之后重试。", "错误");
            }
        }
Exemplo n.º 5
0
        private bool CheckMember(string Name)
        {
            string        SQSTR = $"select * from MemeberInfo where Name='{Name}'";
            SqlConnection OSS   = new OpenSQLSERVER().Start();
            bool          state = new CreateSQLCommand().ExcuteCountNum(OSS, SQSTR);

            if (state == true)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 6
0
        public DeleteUserById(int id)
        {
            int           Lines  = 0;
            SqlConnection DelSQl = null;
            OpenSQLSERVER OSS    = new OpenSQLSERVER();

            DelSQl = OSS.Start();
            SqlCommand SCD = DelSQl.CreateCommand();

            SCD.CommandType = CommandType.Text;
            SCD.CommandText = $"delete from MemeberInfo where id={id}";
            Lines           = SCD.ExecuteNonQuery();
            if (Lines != 0)
            {
                ShowMessageBox SMB = new ShowMessageBox();
                SMB.ShowInforMation("删除成功", "提示");
                MemberInfoForm MIF = new MemberInfoForm();
            }
            else
            {
                //
            }
        }
Exemplo n.º 7
0
 private void ChangeButton_Click(object sender, EventArgs e)
 {
     if (ChangeText.Text.Trim() == "")
     {
         new ShowMessageBox().ShowError("密码不能为空", "错误");
     }
     else
     {
         OpenSQLSERVER OSS          = new OpenSQLSERVER();
         SqlConnection SRLT         = OSS.Start();
         string        ChangeSqlStr = $"update Super_Info set PassWord='******' where UserName='******'";
         int           ResultCode   = new CreateSQLCommand().ExcuteSqlStr(SRLT, ChangeSqlStr);
         if (ResultCode != 0)
         {
             new ShowMessageBox().ShowInforMation("修改成功,密码将在下一次打开软件时生效", "提示");
             this.Close();
         }
         else
         {
             new ShowMessageBox().ShowError("修改失败", "没有找到匹配的用户名");
             this.Close();
         }
     }
 }