示例#1
0
 private void ok_Click(object sender, EventArgs e)//备份
 {
     if (this.filename.Text.Trim() != "")
     {
         SqlConnection connect = InitConnect.GetConnection();
         connect.Open();
         SqlCommand cmd = new SqlCommand("backup database " + InitConnect.GetDatabaseName() + " to disk='" + this.filename.Text.Trim() + "' with init", connect);
         try
         {
             cmd.ExecuteNonQuery();
             MessageBox.Show("您成功备份了数据库!", "恭喜", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
             this.Close();
         }
         catch (Exception ee)
         {
             MessageBox.Show("备份失败!\n错误信息:" + ee.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
         }
         finally
         {
             connect.Close();
         }
     }
     else
     {
         MessageBox.Show("请输入正确的路径及备份文件名称!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
     }
 }
示例#2
0
        /// <summary>
        /// 导入图书信息
        /// </summary>
        private void Book_InfoDataIn()
        {
            SqlConnection connect = InitConnect.GetConnection();

            try
            {
                connect.Open();
                SqlCommand cmd = new SqlCommand();
                if (this.small.Checked)
                {
                    cmd = new SqlCommand("insert into book_info(book_id,book_code,book_name,book_style,book_author,book_publish,book_isbn,book_inprice,book_outprice,book_page,book_bookcase,book_count,book_date,book_in,book_memo,book_cd_case) select book_id,book_code,book_name,book_style,book_author,book_publish,book_isbn,book_inprice,book_outprice,book_page,book_bookcase,book_count,book_date,book_in,book_memo,book_cd_case from opendatasource('Microsoft.Jet.Oledb.4.0','Extended Properties=Excel 5.0;Data Source=" + this.openFileDialog1.FileName + "')...[excel$]", connect);
                }
                else
                {
                    cmd = new SqlCommand("insert into book_info(book_id,book_code,book_name,book_style,book_author,book_publish,book_isbn,book_inprice,book_outprice,book_page,book_bookcase,book_count,book_date,book_in,book_memo,book_cd_case) select book_id,book_code,book_name,book_style,book_author,book_publish,book_isbn,book_inprice,book_outprice,book_page,book_bookcase,book_count,book_date,book_in,book_memo,book_cd_case from opendatasource('Microsoft.ACE.Oledb.12.0','Extended Properties=Excel 12.0;Data Source=" + this.openFileDialog1.FileName + "')...[excel$]", connect);
                }
                cmd.ExecuteNonQuery();
                MessageBox.Show("成功导入了图书信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
            }
            catch (Exception ee)
            {
                MessageBox.Show("导入图书信息失败!\n错误信息:" + ee.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
            }
            finally
            {
                connect.Close();
            }
        }
示例#3
0
 /// <summary>
 /// 确定交易
 /// </summary>
 private void SaleOk()
 {
     if (this.listView1.Items.Count != 0)
     {
         for (int i = 0; i < this.listView1.Items.Count; i++)
         {
             SqlConnection connect = InitConnect.GetConnection();
             connect.Open();
             SqlCommand cmd = new SqlCommand("SaleWare", connect);
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.AddWithValue("@flag", this.book.Checked?this.book.Text.Trim():this.cd.Text.Trim());
             cmd.Parameters.AddWithValue("@id", this.listView1.Items[i].SubItems[1].Text.Trim());
             cmd.Parameters.AddWithValue("@count", int.Parse(this.listView1.Items[i].SubItems[4].Text.Trim()));
             cmd.Parameters.AddWithValue("@date", DateTime.Parse(DateTime.Now.ToShortDateString()));
             cmd.Parameters.AddWithValue("@who", UserInfo.UserID);
             cmd.Parameters.AddWithValue("@vip", this.yes.Checked ? this.vip.Text.Trim() : "");
             cmd.ExecuteNonQuery();
             connect.Close();
         }
         MessageBox.Show("恭喜您,交易成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
         this.listView1.Items.Clear();
         this.money.Text = "0.0";
     }
     else
     {
         MessageBox.Show("没有购买任何商品无法交易!!!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
     }
 }
示例#4
0
        /// <summary>
        /// 显示光盘的详细信息
        /// </summary>
        private void DisplayCd()
        {
            SqlConnection connect = InitConnect.GetConnection();

            connect.Open();
            SqlCommand cmd = new SqlCommand("select * from cd_info where cd_id=@id", connect);

            cmd.Parameters.AddWithValue("@id", this.cdid.Text.Trim());
            SqlDataReader read = cmd.ExecuteReader();

            if (read.Read())
            {
                this.cdcode.Text     = read["cd_code"].ToString().Trim();
                this.cdname.Text     = read["cd_name"].ToString().Trim();
                this.cdstyle.Text    = read["cd_style"].ToString().Trim();
                this.cdauthor.Text   = read["cd_author"].ToString().Trim();
                this.cdpublish.Text  = read["cd_publish"].ToString().Trim();
                this.cdisbn.Text     = read["cd_isbn"].ToString().Trim();
                this.cddate.Value    = DateTime.Parse(read["cd_date"].ToString().Trim());
                this.cdinprice.Text  = read["cd_inprice"].ToString().Trim();
                this.cdoutprice.Text = read["cd_outprice"].ToString().Trim();
                this.cdcase.Text     = read["cd_bookcase"].ToString().Trim();
                this.cddatein.Value  = DateTime.Parse(read["cd_in"].ToString().Trim());
                this.cdmemo.Text     = read["cd_memo"].ToString().Trim();
            }
            else
            {
                this.CdClear(false);
            }
            read.Close();
            connect.Close();
        }
示例#5
0
        private void ShowPower()//列出用户的权限
        {
            for (int i = 0; i < this.checkedListBox1.Items.Count; i++)
            {
                this.checkedListBox1.SetItemCheckState(i, CheckState.Unchecked);
            }
            SqlConnection connect = InitConnect.GetConnection();

            connect.Open();
            SqlCommand cmd = new SqlCommand("select * from power where power_style=@style", connect);

            cmd.Parameters.AddWithValue("@style", this.userstyle.Text.Trim());
            SqlDataReader read = cmd.ExecuteReader();

            while (read.Read())
            {
                for (int i = 0; i < this.checkedListBox1.Items.Count; i++)
                {
                    if (this.checkedListBox1.Items[i].ToString().Trim() == read["power_name"].ToString().Trim())
                    {
                        this.checkedListBox1.SetItemCheckState(i, CheckState.Checked);
                        break;
                    }
                }
            }
            read.Close();
            connect.Close();
        }
示例#6
0
        /// <summary>
        /// 添加或修改时自动设置会员可用的优惠政策
        /// </summary>
        private void SetRebate()
        {
            SqlConnection connect = InitConnect.GetConnection();

            connect.Open();
            SqlCommand cmd = new SqlCommand("SetVipRebate", connect);

            cmd.CommandType = CommandType.StoredProcedure;
            if (this.style.Enabled == false)
            {
                cmd.Parameters.AddWithValue("@rebate", decimal.Parse(((DataRowView)source.Current).Row.ItemArray[1].ToString().Trim()));
            }
            else
            {
                cmd.Parameters.AddWithValue("@rebate", 1);
            }
            SqlDataReader read = cmd.ExecuteReader();

            this.rebate.Items.Clear();
            if (this.style.Enabled == false)
            {
                this.rebate.Items.Add(((DataRowView)source.Current).Row.ItemArray[1].ToString().Trim());
            }
            while (read.Read())
            {
                this.rebate.Items.Add(read["rebate"].ToString().Trim());
            }
            read.Close();
            connect.Close();
        }
示例#7
0
        /// <summary>
        /// 绑定书架
        /// </summary>
        /// <param name="Flag">为1表示绑定querybookcase,为2表示绑定bookcase,为3表示绑定cdcase</param>
        private void BindBookcase(int Flag)
        {
            SqlConnection  connect  = InitConnect.GetConnection();
            SqlDataAdapter bookcase = new SqlDataAdapter("select * from bookcase", connect);
            DataSet        data     = new DataSet();

            bookcase.Fill(data, "bookcase");
            if (Flag == 1)
            {
                this.querybookcase.DataSource    = data.Tables["bookcase"];
                this.querybookcase.DisplayMember = "bookcase_place";
                this.querybookcase.ValueMember   = "bookcase_place";
            }
            else if (Flag == 2)
            {
                this.bookcase.DataSource    = data.Tables["bookcase"];
                this.bookcase.DisplayMember = "bookcase_place";
                this.bookcase.ValueMember   = "bookcase_place";
            }
            else
            {
                this.cdcase.DataSource    = data.Tables["bookcase"];
                this.cdcase.DisplayMember = "bookcase_place";
                this.cdcase.ValueMember   = "bookcase_place";
            }
        }
示例#8
0
        /// <summary>
        /// 显示排行
        /// </summary>
        private void Display()
        {
            this.index.Items.Clear();
            //////////////////////////////////////////
            SqlConnection connect = InitConnect.GetConnection();

            connect.Open();
            SqlCommand cmd = new SqlCommand("SaleIndex", connect);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@ware", this.book.Checked?this.book.Text.Trim():this.cd.Text.Trim());
            cmd.Parameters.AddWithValue("@flag", this.style.SelectedIndex);
            SqlDataReader read  = cmd.ExecuteReader();
            int           count = 1;

            while (read.Read())
            {
                ListViewItem item = this.index.Items.Add(read[0].ToString().Trim());
                for (int i = 1; i < read.FieldCount; i++)
                {
                    item.SubItems.Add(read[i].ToString().Trim());
                }
                item.SubItems.Add(count.ToString().Trim());
                count++;
            }
            read.Close();
            connect.Close();
        }
示例#9
0
        private void Ok_Click(object sender, EventArgs e)//登录系统
        {
            SqlConnection connect = InitConnect.GetConnection();

            connect.Open();
            SqlCommand cmd = new SqlCommand("select count(*) from book_user where user_id=@user and user_pwd=@pwd and user_style=@style", connect);

            cmd.Parameters.AddWithValue("@user", this.textBox1.Text.Trim());
            cmd.Parameters.AddWithValue("@pwd", MD5.MD5String(this.textBox2.Text.Trim()));
            cmd.Parameters.AddWithValue("@style", this.comboBox1.Text.Trim());
            int count = int.Parse(cmd.ExecuteScalar().ToString());

            if (count != 0)
            {
                UserInfo.UserID    = this.textBox1.Text.Trim();
                UserInfo.UserPower = this.comboBox1.Text.Trim();
                this.DialogResult  = DialogResult.OK;
            }
            else
            {
                MessageBox.Show("用户名或密码错误!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                this.comboBox1.Focus();
                this.textBox1.SelectAll();
                this.textBox2.Text = "";
            }
            connect.Close();
        }
示例#10
0
        /// <summary>
        /// 初始化数据
        /// </summary>
        private void InitData()
        {
            SqlConnection connect = InitConnect.GetConnection();
            SqlCommand    select  = new SqlCommand();
            SqlCommand    insert  = new SqlCommand();
            SqlCommand    delete  = new SqlCommand();

            user_style.SelectCommand             = select;
            user_style.SelectCommand.Connection  = connect;
            user_style.SelectCommand.CommandText = "select userstyle_name as 用户类型 from user_style where 1=0";
            ///////////////////////////////////////////////////////////////
            user_style.InsertCommand             = insert;
            user_style.InsertCommand.Connection  = connect;
            user_style.InsertCommand.CommandText = "insert into user_style(userstyle_name) values(@name)";
            user_style.InsertCommand.Parameters.Add("@name", SqlDbType.VarChar, 0, "用户类型");
            /////////////////////////////////////////////////////////////
            user_style.DeleteCommand             = delete;
            user_style.DeleteCommand.Connection  = connect;
            user_style.DeleteCommand.CommandText = "delete user_style where userstyle_name=@name";
            user_style.DeleteCommand.Parameters.Add("@name", SqlDbType.VarChar, 0, "用户类型");
            /////////////////////////////////////////////////////////
            user_style.Fill(data, "user_style");
            source.DataSource             = data;
            source.DataMember             = "user_style";
            this.dataGridView1.DataSource = source;
            ////////////////////////////////////////////////////////////
            this.style.DataBindings.Add("Text", source, "用户类型", true);
        }
示例#11
0
        /// <summary>
        /// 初始化数据
        /// </summary>
        private void InitData()
        {
            SqlConnection connect = InitConnect.GetConnection();
            SqlCommand    select  = new SqlCommand();
            SqlCommand    insert  = new SqlCommand();
            SqlCommand    delete  = new SqlCommand();

            bookcase.SelectCommand             = select;
            bookcase.SelectCommand.Connection  = connect;
            bookcase.SelectCommand.CommandText = "select bookcase_place as 书架位置 from bookcase where 1=0";
            //////////////////////////////////////////////////////////
            bookcase.InsertCommand             = insert;
            bookcase.InsertCommand.Connection  = connect;
            bookcase.InsertCommand.CommandText = "insert into bookcase(bookcase_place) values(@place)";
            bookcase.InsertCommand.Parameters.Add("@place", SqlDbType.VarChar, 0, "书架位置");
            //////////////////////////////////////////////////////////
            bookcase.DeleteCommand             = delete;
            bookcase.DeleteCommand.Connection  = connect;
            bookcase.DeleteCommand.CommandText = "delete bookcase where bookcase_place=@place";
            bookcase.DeleteCommand.Parameters.Add("@place", SqlDbType.VarChar, 0, "书架位置");
            //////////////////////////////////////////////////////////
            bookcase.Fill(data, "bookcase");
            source.DataSource             = data;
            source.DataMember             = "bookcase";
            this.dataGridView1.DataSource = source;
            ///////////////////////////////////////////////////////////
            this.place.DataBindings.Add("Text", source, "书架位置", true);
        }
示例#12
0
        /// <summary>
        /// 导入 供应商信息
        /// </summary>
        private void ProviderDataIn()
        {
            SqlConnection connect = InitConnect.GetConnection();

            try
            {
                connect.Open();
                SqlCommand cmd = new SqlCommand();
                if (this.small.Checked)
                {
                    cmd = new SqlCommand("insert into provider(provider_id,provider_name,provider_address,provider_post,provider_tel,provider_fax) select provider_id,provider_name,provider_address,provider_post,provider_tel,provider_fax from opendatasource('Microsoft.Jet.Oledb.4.0','Extended Properties=Excel 5.0;Data Source=" + this.openFileDialog1.FileName + "')...[excel$]", connect);
                }
                else
                {
                    cmd = new SqlCommand("insert into provider(provider_id,provider_name,provider_address,provider_post,provider_tel,provider_fax) select provider_id,provider_name,provider_address,provider_post,provider_tel,provider_fax from opendatasource('Microsoft.ACE.Oledb.12.0','Extended Properties=Excel 12.0;Data Source=" + this.openFileDialog1.FileName + "')...[excel$]", connect);
                }
                cmd.ExecuteNonQuery();
                MessageBox.Show("成功导入了供应商信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
            }
            catch (Exception ee)
            {
                MessageBox.Show("导入供应商信息失败!\n错误信息:" + ee.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
            }
            finally
            {
                connect.Close();
            }
        }
示例#13
0
 private void warereturn_Click(object sender, EventArgs e)//顾客退货
 {
     if (this.view.Items.Count != 0)
     {
         for (int i = 0; i < this.view.Items.Count; i++)
         {
             SqlConnection connect = InitConnect.GetConnection();
             connect.Open();
             SqlCommand cmd = new SqlCommand("WareReturn", connect);
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.AddWithValue("@style", this.book.Checked?this.book.Text.Trim():this.cd.Text.Trim());
             cmd.Parameters.AddWithValue("@id", this.view.Items[i].SubItems[1].Text.Trim());
             cmd.Parameters.AddWithValue("@sale", DateTime.Parse(this.saledate.Value.ToShortDateString()));
             cmd.Parameters.AddWithValue("@date", DateTime.Parse(DateTime.Now.ToShortDateString()));
             cmd.Parameters.AddWithValue("@count", int.Parse(this.count.Text.Trim()));
             cmd.Parameters.AddWithValue("@who", UserInfo.UserID);
             cmd.Parameters.AddWithValue("@memo", this.reason.Text.Trim());
             cmd.ExecuteNonQuery();
             connect.Close();
         }
         this.view.Items.Clear();
         this.ReturnCount();
         this.ReturnMoney();
         MessageBox.Show("顾客退货成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
     }
     else
     {
         MessageBox.Show("没有顾客来退货!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
     }
 }
示例#14
0
        /// <summary>
        /// 设置用户的权限
        /// </summary>
        private void SetUserPower()
        {
            this.button1.Enabled    = false;
            this.menublock1.Enabled = false;
            this.button2.Enabled    = false;
            this.menublock2.Enabled = false;
            this.button3.Enabled    = false;
            this.menublock3.Enabled = false;
            this.button4.Enabled    = false;
            this.menublock4.Enabled = false;
            this.button5.Enabled    = false;
            this.menublock5.Enabled = false;
            this.button6.Enabled    = false;
            this.menublock6.Enabled = false;
            /////////////////////////////////////////////////////////////////////////////////////////
            SqlConnection connect = InitConnect.GetConnection();

            connect.Open();
            SqlCommand cmd = new SqlCommand("select * from power where power_style=@style", connect);

            cmd.Parameters.AddWithValue("@style", UserInfo.UserPower);
            SqlDataReader read = cmd.ExecuteReader();

            while (read.Read())
            {
                if (read["power_name"].ToString().Trim() == "系统设置")
                {
                    this.button1.Enabled    = true;
                    this.menublock1.Enabled = true;
                }
                else if (read["power_name"].ToString().Trim() == "基本资料维护")
                {
                    this.button2.Enabled    = true;
                    this.menublock2.Enabled = true;
                }
                else if (read["power_name"].ToString().Trim() == "采购管理")
                {
                    this.button3.Enabled    = true;
                    this.menublock3.Enabled = true;
                }
                else if (read["power_name"].ToString().Trim() == "销售管理")
                {
                    this.button4.Enabled    = true;
                    this.menublock4.Enabled = true;
                }
                else if (read["power_name"].ToString().Trim() == "库存管理")
                {
                    this.button5.Enabled    = true;
                    this.menublock5.Enabled = true;
                }
                else if (read["power_name"].ToString().Trim() == "系统数据管理")
                {
                    this.button6.Enabled    = true;
                    this.menublock6.Enabled = true;
                }
            }
            read.Close();
            connect.Close();
        }
示例#15
0
        /// <summary>
        /// 还原数据库前use其它数据库
        /// </summary>
        private void UseOtherDatabase()
        {
            SqlConnection connect = InitConnect.GetConnection();

            connect.Open();
            SqlCommand cmd = new SqlCommand("use master", connect);

            cmd.ExecuteNonQuery();
            connect.Close();
        }
示例#16
0
        private void InitData()
        {
            SqlConnection connect = InitConnect.GetConnection();
            SqlCommand    select  = new SqlCommand();
            SqlCommand    insert  = new SqlCommand();
            SqlCommand    update  = new SqlCommand();
            SqlCommand    delete  = new SqlCommand();

            vip.SelectCommand             = select;
            vip.SelectCommand.Connection  = connect;
            vip.SelectCommand.CommandText = "select vip_id as 会员号,vip_name as 会员姓名,vip_sex as 性别,vip_tel as 电话,vip_address as 地址,vip_identity as 身份证号,vip_style as 会员类型,vip_date as 办理时间 from vip where 1=0";
            /////////////////////////////////////////////////////////
            vip.InsertCommand             = insert;
            vip.InsertCommand.Connection  = connect;
            vip.InsertCommand.CommandText = "insert into vip(vip_id,vip_name,vip_sex,vip_tel,vip_address,vip_identity,vip_style,vip_date) values(@id,@name,@sex,@tel,@address,@identity,@style,@date)";
            vip.InsertCommand.Parameters.Add("@id", SqlDbType.Char, 0, "会员号");
            vip.InsertCommand.Parameters.Add("@name", SqlDbType.VarChar, 0, "会员姓名");
            vip.InsertCommand.Parameters.Add("@sex", SqlDbType.Char, 0, "性别");
            vip.InsertCommand.Parameters.Add("@tel", SqlDbType.VarChar, 0, "电话");
            vip.InsertCommand.Parameters.Add("@address", SqlDbType.VarChar, 0, "地址");
            vip.InsertCommand.Parameters.Add("@identity", SqlDbType.Char, 0, "身份证号");
            vip.InsertCommand.Parameters.Add("@style", SqlDbType.VarChar, 0, "会员类型");
            vip.InsertCommand.Parameters.Add("@date", SqlDbType.DateTime, 0, "办理时间");
            //////////////////////////////////////////////////////////
            vip.UpdateCommand             = update;
            vip.UpdateCommand.Connection  = connect;
            vip.UpdateCommand.CommandText = "update vip set vip_name=@name,vip_sex=@sex,vip_tel=@tel,vip_address=@address,vip_identity=@identity,vip_style=@style,vip_date=@date where vip_id=@id";
            vip.UpdateCommand.Parameters.Add("@id", SqlDbType.Char, 0, "会员号");
            vip.UpdateCommand.Parameters.Add("@name", SqlDbType.VarChar, 0, "会员姓名");
            vip.UpdateCommand.Parameters.Add("@sex", SqlDbType.Char, 0, "性别");
            vip.UpdateCommand.Parameters.Add("@tel", SqlDbType.VarChar, 0, "电话");
            vip.UpdateCommand.Parameters.Add("@address", SqlDbType.VarChar, 0, "地址");
            vip.UpdateCommand.Parameters.Add("@identity", SqlDbType.Char, 0, "身份证号");
            vip.UpdateCommand.Parameters.Add("@style", SqlDbType.VarChar, 0, "会员类型");
            vip.UpdateCommand.Parameters.Add("@date", SqlDbType.DateTime, 0, "办理时间");
            ///////////////////////////////////////////////////
            vip.DeleteCommand             = delete;
            vip.DeleteCommand.Connection  = connect;
            vip.DeleteCommand.CommandText = "delete vip where vip_id=@id";
            vip.DeleteCommand.Parameters.Add("@id", SqlDbType.Char, 0, "会员号");
            //////////////////////////////////////////////////////////////
            vip.Fill(data, "vip");
            source.DataSource             = data;
            source.DataMember             = "vip";
            this.dataGridView1.DataSource = source;
            /////////////////////////////////////////////
            this.id.DataBindings.Add("Text", source, "会员号", true);
            this.name.DataBindings.Add("Text", source, "会员姓名", true);
            this.sex.DataBindings.Add("Text", source, "性别", true);
            this.tel.DataBindings.Add("Text", source, "电话", true);
            this.address.DataBindings.Add("Text", source, "地址", true);
            this.identity.DataBindings.Add("Text", source, "身份证号", true);
            this.style.DataBindings.Add("SelectedValue", source, "会员类型", true);
            this.date.DataBindings.Add("Value", source, "办理时间", true);
        }
示例#17
0
        private void DisplayStyle()//列出所有用户的类型
        {
            SqlConnection  connect = InitConnect.GetConnection();
            DataSet        data    = new DataSet();
            SqlDataAdapter adapter = new SqlDataAdapter("select * from user_style", connect);

            adapter.Fill(data, "user_style");
            this.comboBox1.DataSource    = data.Tables["user_style"];
            this.comboBox1.DisplayMember = "userstyle_name";
            this.comboBox1.ValueMember   = "userstyle_name";
        }
示例#18
0
        /// <summary>
        /// 绑定用户类型
        /// </summary>
        private void BindUserStyle()
        {
            SqlConnection  connect = InitConnect.GetConnection();
            SqlDataAdapter adapter = new SqlDataAdapter("select * from user_style", connect);
            DataSet        dataset = new DataSet();

            adapter.Fill(dataset, "user_style");
            this.style.DataSource    = dataset.Tables["user_style"];
            this.style.DisplayMember = "userstyle_name";
            this.style.ValueMember   = "userstyle_name";
        }
示例#19
0
        /// <summary>
        /// 是否设置了系统的上下限
        /// </summary>
        /// <returns>返回true表示设置了,否则表示没有设置</returns>
        private bool IsConfig()
        {
            SqlConnection connect = InitConnect.GetConnection();

            connect.Open();
            SqlCommand cmd    = new SqlCommand("select count(*) from book_updown", connect);
            string     result = cmd.ExecuteScalar().ToString().Trim();

            connect.Close();
            return(result != "0");
        }
示例#20
0
        ///<summary>
        ///绑定书架
        ///</summary>
        private void BindBookcase()
        {
            SqlConnection  connect  = InitConnect.GetConnection();
            SqlDataAdapter bookcase = new SqlDataAdapter("select * from bookcase", connect);
            DataSet        data     = new DataSet();

            bookcase.Fill(data, "bookcase");
            this.bookcase.DataSource    = data.Tables["bookcase"];
            this.bookcase.DisplayMember = "bookcase_place";
            this.bookcase.ValueMember   = "bookcase_place";
        }
示例#21
0
        /// <summary>
        /// 默认设置
        /// </summary>
        private void DefaultConfig()
        {
            SqlConnection connect = InitConnect.GetConnection();

            connect.Open();
            SqlCommand cmd = new SqlCommand("insert into book_updown(updown_style,updown_count) values('上限',0)", connect);

            cmd.ExecuteNonQuery();
            cmd = new SqlCommand("insert into book_updown(updown_style,updown_count) values('下限',0)", connect);
            cmd.ExecuteNonQuery();
            connect.Close();
        }
示例#22
0
        private void BindUserStyle()//绑定用户类型
        {
            SqlConnection  connect   = InitConnect.GetConnection();
            SqlDataAdapter book_user = new SqlDataAdapter("select * from user_style", connect);
            DataSet        data      = new DataSet();

            data.Clear();
            book_user.Fill(data, "user_style");
            this.userstyle.DataSource    = data.Tables["user_style"];
            this.userstyle.DisplayMember = "userstyle_name";
            this.userstyle.ValueMember   = "userstyle_name";
        }
示例#23
0
        /// <summary>
        /// 显示图书的详细信息
        /// </summary>
        private void BindBook()
        {
            SqlConnection  connect = InitConnect.GetConnection();
            DataSet        data    = new DataSet();
            SqlDataAdapter adapter = new SqlDataAdapter("select book_id as 图书编号,book_code as 条形码,book_name as 图书名称,book_style as 图书类型,book_publish as 出版社,book_count as 库存量 from book_info", connect);

            data.Clear();
            adapter.Fill(data, "book_info");
            booksource                   = new BindingSource(data, "book_info");
            booksource.Filter            = "图书编号 like '" + this.bookid.Text.Trim() + "%'";
            this.bookshowinfo.DataSource = booksource;
        }
示例#24
0
        /// <summary>
        /// 显示光盘的详细信息
        /// </summary>
        private void BindCd()
        {
            SqlConnection  connect = InitConnect.GetConnection();
            DataSet        data    = new DataSet();
            SqlDataAdapter adapter = new SqlDataAdapter("select cd_id as 光盘编号,cd_code as 条形码,cd_name as 光盘名称,cd_style as 光盘类型,cd_publish as 出版社,cd_count as 库存量 from cd_info", connect);

            data.Clear();
            adapter.Fill(data, "cd_info");
            cdsource                   = new BindingSource(data, "cd_info");
            cdsource.Filter            = "光盘编号 like '" + this.cdid.Text.Trim() + "%'";
            this.cdshowinfo.DataSource = cdsource;
        }
示例#25
0
        /// <summary>
        /// 默认设置
        /// </summary>
        private void DefaultConfig()
        {
            SqlConnection connect = InitConnect.GetConnection();

            connect.Open();
            SqlCommand cmd = new SqlCommand("insert into back_return(back_return_name,back_return_count) values('光盘',0)", connect);

            cmd.ExecuteNonQuery();
            cmd = new SqlCommand("insert into back_return(back_return_name,back_return_count) values('图书',0)", connect);
            cmd.ExecuteNonQuery();
            connect.Close();
        }
示例#26
0
        /// <summary>
        /// 初始化数据
        /// </summary>
        private void InitData()
        {
            SqlConnection connect = InitConnect.GetConnection();
            SqlCommand    select  = new SqlCommand();
            SqlCommand    insert  = new SqlCommand();
            SqlCommand    update  = new SqlCommand();
            SqlCommand    delete  = new SqlCommand();

            book_user.SelectCommand             = select;
            book_user.SelectCommand.Connection  = connect;
            book_user.SelectCommand.CommandText = "select user_id as 用户名,user_pwd as 密码,user_name as 姓名,user_sex as 性别,user_tel as 电话,user_address as 地址,user_style as 用户类型 from book_user where 1=0";
            ///////////////////////////////////////////////////////////////
            book_user.InsertCommand             = insert;
            book_user.InsertCommand.Connection  = connect;
            book_user.InsertCommand.CommandText = "insert into book_user(user_id,user_pwd,user_name,user_sex,user_tel,user_address,user_style) values(@id,@pwd,@name,@sex,@tel,@address,@style)";
            book_user.InsertCommand.Parameters.Add("@id", SqlDbType.VarChar, 0, "用户名");
            book_user.InsertCommand.Parameters.Add("@pwd", SqlDbType.VarChar, 0, "密码");
            book_user.InsertCommand.Parameters.Add("@name", SqlDbType.VarChar, 0, "姓名");
            book_user.InsertCommand.Parameters.Add("@sex", SqlDbType.Char, 0, "性别");
            book_user.InsertCommand.Parameters.Add("@tel", SqlDbType.VarChar, 0, "电话");
            book_user.InsertCommand.Parameters.Add("@address", SqlDbType.VarChar, 0, "地址");
            book_user.InsertCommand.Parameters.Add("@style", SqlDbType.VarChar, 0, "用户类型");
            /////////////////////////////////////////////////////////////////
            book_user.UpdateCommand             = update;
            book_user.UpdateCommand.Connection  = connect;
            book_user.UpdateCommand.CommandText = "update book_user set user_pwd=@pwd,user_name=@name,user_sex=@sex,user_tel=@tel,user_address=@address,user_style=@style where user_id=@id";
            book_user.UpdateCommand.Parameters.Add("@id", SqlDbType.VarChar, 0, "用户名");
            book_user.UpdateCommand.Parameters.Add("@pwd", SqlDbType.VarChar, 0, "密码");
            book_user.UpdateCommand.Parameters.Add("@name", SqlDbType.VarChar, 0, "姓名");
            book_user.UpdateCommand.Parameters.Add("@sex", SqlDbType.Char, 0, "性别");
            book_user.UpdateCommand.Parameters.Add("@tel", SqlDbType.VarChar, 0, "电话");
            book_user.UpdateCommand.Parameters.Add("@address", SqlDbType.VarChar, 0, "地址");
            book_user.UpdateCommand.Parameters.Add("@style", SqlDbType.VarChar, 0, "用户类型");
            ///////////////////////////////////////////////////////////////////
            book_user.DeleteCommand             = delete;
            book_user.DeleteCommand.Connection  = connect;
            book_user.DeleteCommand.CommandText = "delete book_user where user_id=@id";
            book_user.DeleteCommand.Parameters.Add("@id", SqlDbType.VarChar, 0, "用户名");
            ///////////////////////////////////////////////////////////////////
            book_user.Fill(data, "book_user");
            source.DataSource             = data;
            source.DataMember             = "book_user";
            this.dataGridView1.DataSource = source;
            //////////////////////////////////////////////////////////////
            this.id.DataBindings.Add("Text", source, "用户名", true);
            this.pwd.DataBindings.Add("Text", source, "密码", true);
            this.name.DataBindings.Add("Text", source, "姓名", true);
            this.sex.DataBindings.Add("Text", source, "性别", true);
            this.tel.DataBindings.Add("Text", source, "电话", true);
            this.address.DataBindings.Add("Text", source, "地址", true);
            this.style.DataBindings.Add("SelectedValue", source, "用户类型", true);
        }
示例#27
0
        /// <summary>
        /// 获取当前用户的当前密码
        /// </summary>
        /// <returns>当前密码</returns>
        private string GetPwd()
        {
            SqlConnection connect = InitConnect.GetConnection();

            connect.Open();
            SqlCommand cmd = new SqlCommand("select user_pwd from book_user where user_id=@id", connect);

            cmd.Parameters.AddWithValue("@id", UserInfo.UserID.Trim());
            string password = cmd.ExecuteScalar().ToString().Trim();

            connect.Close();
            return(password);
        }
示例#28
0
        /// <summary>
        /// 绑定出版社
        /// </summary>
        private void BindPublish()
        {
            string         ware    = this.book.Checked ? "图书" : "光盘";
            SqlConnection  connect = InitConnect.GetConnection();
            DataSet        data    = new DataSet();
            SqlDataAdapter adapter = new SqlDataAdapter("select * from publish where publish_style='" + ware + "'", connect);

            data.Clear();
            adapter.Fill(data, "publish");
            this.publish.DataSource    = data.Tables["publish"];
            this.publish.DisplayMember = "publish_name";
            this.publish.ValueMember   = "publish_name";
        }
示例#29
0
        /// <summary>
        /// 绑定商品类型
        /// </summary>
        private void BindStyle()
        {
            string         ware    = this.book.Checked ? "图书" : "光盘";
            SqlConnection  connect = InitConnect.GetConnection();
            DataSet        data    = new DataSet();
            SqlDataAdapter adapter = new SqlDataAdapter("select * from book_style where bookstyle_style='" + ware + "'", connect);

            data.Clear();
            adapter.Fill(data, "book_style");
            this.style.DataSource    = data.Tables["book_style"];
            this.style.DisplayMember = "bookstyle_name";
            this.style.ValueMember   = "bookstyle_name";
        }
示例#30
0
        /// <summary>
        /// 什么时候显示光盘信息
        /// </summary>
        /// <returns>true表示显示,反之表示不显示</returns>
        private bool DisplayCdInfo()
        {
            SqlConnection connect = InitConnect.GetConnection();

            connect.Open();
            SqlCommand cmd = new SqlCommand("select count(*) from cd_info where cd_id like @id", connect);

            cmd.Parameters.AddWithValue("@id", this.cdid.Text.Trim() + "%");
            int count = int.Parse(cmd.ExecuteScalar().ToString().Trim());

            connect.Close();
            return(count > 0);
        }