コード例 #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            Task.Factory.StartNew(() =>
            {
                LoadForm.ShowLoading(this);
                try
                {
                    var mongoTool = MongoDBTool.Connect(connectStr);

                    var dataBaseNames = mongoTool.GetDataBases();

                    var dataBaseName = "";

                    if (dataBaseNames != null && dataBaseNames.Any())
                    {
                        if (System.Linq.Enumerable.Count(dataBaseNames) == 1)
                        {
                            dataBaseName = dataBaseNames.First();
                        }
                        else
                        {
                            dataBaseName = "all";
                        }
                    }

                    this.Invoke(new Action(() =>
                    {
                        Connection connectionModel       = new Connection();
                        connectionModel.Database         = dataBaseName;
                        connectionModel.ID               = Guid.NewGuid();
                        connectionModel.Name             = mongoTool.ServerInfo + "(MongoDB)[" + connectionModel.Database + "]";
                        connectionModel.DbType           = DatabaseType.MongoDB.ToString();
                        connectionModel.ConnectionString = connectStr;

                        UtilsHelper.AddConnection(connectionModel);

                        this.DialogResult = DialogResult.OK;

                        this.Close();
                    }));
                }
                catch (Exception ex)
                {
                    MessageBox.Show("连接失败!\n\r" + ex.Message);
                }
                LoadForm.HideLoading();
            });
        }
コード例 #2
0
        //构造函数接收传入的ListView子项类型
        public ModifyUserInfo(ListViewItem.ListViewSubItemCollection listViewSubItem)
        {
            InitializeComponent();

            this.Text = LoadForm.TextList[int.Parse(this.Tag.ToString())];

            LoadForm.LoadText(this);

            conn           = Program.ConDataBase();
            cmd            = new MySqlCommand();
            cmd.Connection = conn;

            //查询并设置会员等级选项
            string sql = "select name from user_rank order by discount_rate desc";

            cmd = new MySqlCommand(sql, conn);
            MySqlDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                string data = reader[0].ToString();
                user_rank_cbb.Items.Add(data);
            }
            cmd.Dispose();
            reader.Close();

            //查询并设置会员状态选项
            sql    = "select name from user_status";
            cmd    = new MySqlCommand(sql, conn);
            reader = cmd.ExecuteReader();
            while (reader.Read())
            {
                string data = reader[0].ToString();
                user_status_cbb.Items.Add(data);
            }
            cmd.Dispose();
            reader.Close();

            //通过接收的ListView子项显示当前选中的会员信息
            id                     = int.Parse(listViewSubItem[0].Text);
            name_txb.Text          = listViewSubItem[1].Text;
            sex_cbb.Text           = listViewSubItem[2].Text;
            tel_txb.Text           = listViewSubItem[3].Text;
            user_rank_cbb.Text     = listViewSubItem[8].Text;
            user_status_cbb.Text   = listViewSubItem[9].Text;
            expired_time_dtp.Value = Convert.ToDateTime(listViewSubItem[12].Text.ToString());
            remarks_txb.Text       = listViewSubItem[13].Text;
        }
コード例 #3
0
        public static void Init()
        {
            string constring = "server=db4free.net;port=3306;database=tictactoecl;user=admincl;password=myadmin";

            connection = new MySqlConnection(constring);
            try
            {
                Connect();
                LoadForm load = new LoadForm();
                load.ShowDialog();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #4
0
        //构造函数接收传入的ListView子项类型
        public ModifyUserRank(ListViewItem.ListViewSubItemCollection listViewSubItem, string first_rank_name)
        {
            InitializeComponent();

            this.Text = LoadForm.TextList[int.Parse(this.Tag.ToString())];
            LoadForm.LoadText(this);

            conn           = Program.ConDataBase();
            cmd            = new MySqlCommand();
            cmd.Connection = conn;

            id = listViewSubItem[0].Tag.ToString();   //设置当前选中会员等级的id
            this.first_rank_name   = first_rank_name; //设置传入的第一个等级的名称
            rank_name              = listViewSubItem[0].Text;
            rank_name_txb.Text     = listViewSubItem[0].Text;
            discount_rate_txb.Text = listViewSubItem[1].Text;
        }
コード例 #5
0
        //构造函数接收传入的是否正在选择供应商bool值
        public SupplierManage(bool isSelectingSupplier)
        {
            InitializeComponent();

            this.Text = LoadForm.TextList[int.Parse(this.Tag.ToString())];
            LoadForm.LoadText(this);

            conn           = Program.ConDataBase();
            cmd            = new MySqlCommand();
            cmd.Connection = conn;

            //如果正在选择供应商,设置新增供应商分区不可用
            create_supplier_gpb.Enabled = !isSelectingSupplier;
            this.isSelectingSupplier    = isSelectingSupplier;

            SelectSupplier("select * from supplier");
        }
コード例 #6
0
        //构造函数接收传入的ListView子项类型
        public UserCharge(ListViewItem.ListViewSubItemCollection listViewSubItem)
        {
            InitializeComponent();

            this.Text = LoadForm.TextList[int.Parse(this.Tag.ToString())];
            LoadForm.LoadText(this);

            conn           = Program.ConDataBase();
            cmd            = new MySqlCommand();
            cmd.Connection = conn;

            //通过接收的ListView子项显示当前选中的会员信息(不可编辑)
            id_txb.Text        = listViewSubItem[0].Text.ToString();
            name_txb.Text      = listViewSubItem[1].Text.ToString();
            tel_txb.Text       = listViewSubItem[3].Text.ToString();
            balance_txb.Text   = listViewSubItem[5].Text.ToString();
            total_num_txb.Text = listViewSubItem[6].Text.ToString();
        }
コード例 #7
0
        public GoodsList()
        {
            InitializeComponent();

            this.Text = LoadForm.TextList[int.Parse(this.Tag.ToString())];
            LoadForm.LoadText(this);

            conn           = Program.ConDataBase();
            cmd            = new MySqlCommand();
            cmd.Connection = conn;

            SelectGoods("SELECT g.id, g.`name`, g.type, g.stock_num, g.sold_num, g.sell_price, g.purchase_price, g.stock_time, s.`name` as sName FROM goods as g, supplier as s WHERE g.supplier_id = s.id");

            //调用AddNodes方法,传入默认根节点,初始化商品分类树
            AddNodes(by_type_tvw.Nodes[0], 1);
            AddNodes(by_type_tvw.Nodes[1], 2);
            by_type_tvw.ExpandAll();
        }
コード例 #8
0
        //构造函数接收传入的ListView子项类型
        public ModifySupplierInfo(ListViewItem.ListViewSubItemCollection listViewSubItem)
        {
            InitializeComponent();

            this.Text = LoadForm.TextList[int.Parse(this.Tag.ToString())];
            LoadForm.LoadText(this);

            conn           = Program.ConDataBase();
            cmd            = new MySqlCommand();
            cmd.Connection = conn;

            //设置各供应商信息为传入的供应商信息
            id               = int.Parse(listViewSubItem[0].Text);
            name_txb.Text    = listViewSubItem[1].Text;
            tel_txb.Text     = listViewSubItem[2].Text;
            address_txb.Text = listViewSubItem[3].Text;
            remarks_txb.Text = listViewSubItem[6].Text;
        }
コード例 #9
0
        private void HomeDelivery_Load(object sender, EventArgs e)
        {
            LoadForm.centerForm(this);
            cbxReceptionEmployee.Text = "Recepcionista";
            cbxAtendedEmployee.Text   = "Repartidor";
            cbxClients.Text           = "Clientes";

            List <String> nameClients = new List <string>();

            foreach (var item in client_Logic.getClient())
            {
                nameClients.Add($"{item.id_client} - {item.first_client} {item.last_client}");
            }

            LoadForm.fillCbx(cbxReceptionEmployee, employee_Logic.getReceptorEmployee());
            LoadForm.fillCbx(cbxAtendedEmployee, employee_Logic.getDeliveryEmployee());
            LoadForm.fillCbx(cbxClients, nameClients);
            fillListView();
        }
コード例 #10
0
        public UserList()
        {
            InitializeComponent();

            this.Text = LoadForm.TextList[int.Parse(this.Tag.ToString())];
            LoadForm.LoadText(this);

            conn           = Program.ConDataBase();
            cmd            = new MySqlCommand();
            cmd.Connection = conn;

            //显示所有会员
            SelectUser("select * from user");

            //设置性别默认值
            by_sex_cbb.SelectedIndex = 2;

            //设置TreeView中会员等级节点
            string sql = "select name from user_rank order by discount_rate desc";

            cmd = new MySqlCommand(sql, conn);
            MySqlDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                by_type_tvw.Nodes[0].Nodes.Add(reader[0].ToString());
            }
            cmd.Dispose();
            reader.Close();

            //设置TreeView中会员状态节点
            sql    = "select name from user_status";
            cmd    = new MySqlCommand(sql, conn);
            reader = cmd.ExecuteReader();
            while (reader.Read())
            {
                by_type_tvw.Nodes[1].Nodes.Add(reader[0].ToString());
            }
            cmd.Dispose();
            reader.Close();

            by_type_tvw.ExpandAll();
        }
コード例 #11
0
        //构造函数接收传入的是否正在选择商品分类bool值
        public SetGoodsType(bool isSelectingType)
        {
            InitializeComponent();

            this.Text = LoadForm.TextList[int.Parse(this.Tag.ToString())];
            LoadForm.LoadText(this);

            conn           = Program.ConDataBase();
            cmd            = new MySqlCommand();
            cmd.Connection = conn;

            //如果正在选择商品分类,设置编辑商品分类分区不可用
            modify_goods_type_gpb.Enabled = !isSelectingType;
            this.isSelectingType          = isSelectingType;

            ////调用AddNodes方法,传入默认根节点,初始化商品分类树
            AddNodes(goods_type_tvw.Nodes[0], 1);
            AddNodes(goods_type_tvw.Nodes[1], 2);
            goods_type_tvw.ExpandAll();
        }
コード例 #12
0
        //构造函数接收传入的ListView子项类型
        public ModifyGoodsInfo(ListViewItem.ListViewSubItemCollection listViewSubItem)
        {
            InitializeComponent();

            this.Text = LoadForm.TextList[int.Parse(this.Tag.ToString())];
            LoadForm.LoadText(this);

            conn           = Program.ConDataBase();
            cmd            = new MySqlCommand();
            cmd.Connection = conn;

            //设置各商品信息为传入的商品信息
            id                         = int.Parse(listViewSubItem[0].Text);
            goods_name                 = listViewSubItem[1].Text;
            goods_name_txb.Text        = listViewSubItem[1].Text;
            select_goods_type_btn.Text = listViewSubItem[2].Text;
            stock_num_txb.Text         = listViewSubItem[3].Text;
            sell_price_txb.Text        = listViewSubItem[5].Text;
            purchase_price_txb.Text    = listViewSubItem[6].Text;
            select_supplier_btn.Text   = listViewSubItem[8].Text;
        }
コード例 #13
0
        private void HomeBill_Load(object sender, EventArgs e)
        {
            LoadForm.centerForm(this);
            string fullName = $"{LoadForm.client.first_client} {LoadForm.client.last_client}";

            txtAdress.Text = LoadForm.client.address;
            txtNIT.Text    = LoadForm.client.nit_client.ToString();
            txtName.Text   = fullName;
            lblIDUser.Text = LoadForm.client.idDBClient.ToString();

            float totalPrice = 0;

            if (HomeDelivery.ListSaucers.saucers.Count > 0)
            {
                foreach (var item in HomeDelivery.ListSaucers.saucers)
                {
                    string saucer = $"Q.{item.costSaucer} - {item.nameSaucer}\n";
                    listSaucer.Items.Add(saucer);
                    totalPrice += item.costSaucer;
                }
            }

            lblPrice.Text = $"{totalPrice.ToString()}";
        }
コード例 #14
0
        /// <summary>
        /// 确定
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button2_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(cbbServer.Text))
            {
                MessageBox.Show("服务器不能为空!");
                return;
            }

            if (cbbShenFenRZ.SelectedIndex == 1 && string.IsNullOrEmpty(txtUserName.Text))
            {
                MessageBox.Show("登陆名不能为空!");
                return;
            }

            string tempconnectionstring = createConnectionString(cbbDatabase.SelectedIndex == 0 ? "master" : cbbDatabase.Text);

            Task.Factory.StartNew(() =>
            {
                LoadForm.ShowLoading(this);

                try
                {
                    using (SqlConnection conn = new SqlConnection(tempconnectionstring))
                    {
                        conn.Open();
                    }
                    LoadForm.HideLoading();

                    Dictionary <string, string> dic = new Dictionary <string, string>();

                    this.Invoke(new Action(() =>
                    {
                        if (checkBox1.Checked)
                        {
                            var cnnStr = textBox1.Text;

                            var arr1 = cnnStr.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);

                            foreach (var item in arr1)
                            {
                                var arr2 = item.Split(new string[] { "=" }, StringSplitOptions.RemoveEmptyEntries);

                                try
                                {
                                    dic.Add(arr2[0].ToLower(), arr2[1].ToLower());
                                }
                                catch { }
                            }


                            Connection connectionModel = new Connection();
                            connectionModel.Database   = dic["initial catalog"];
                            connectionModel.ID         = Guid.NewGuid();
                            connectionModel.Name       = dic["data source"] + "(" + DatabaseType.SqlServer9.ToString() + ")[" + connectionModel.Database + "]";

                            connectionModel.DbType           = DatabaseType.SqlServer9.ToString();
                            connectionModel.ConnectionString = tempconnectionstring;
                            UtilsHelper.AddConnection(connectionModel);
                            this.DialogResult = DialogResult.OK;
                            this.Close();
                        }
                        else
                        {
                            Connection connectionModel = new Connection();
                            connectionModel.Database   = cbbDatabase.SelectedIndex == 0 ? "all" : cbbDatabase.Text;
                            connectionModel.ID         = Guid.NewGuid();
                            connectionModel.Name       = cbbServer.Text + "(" + cbbServerType.Text + ")[" + connectionModel.Database + "]";
                            if (cbbServerType.SelectedIndex == 0)
                            {
                                connectionModel.DbType = DatabaseType.SqlServer.ToString();
                            }
                            else
                            {
                                connectionModel.DbType = DatabaseType.SqlServer9.ToString();
                            }
                            connectionModel.ConnectionString = tempconnectionstring;

                            UtilsHelper.AddConnection(connectionModel);

                            this.DialogResult = DialogResult.OK;

                            this.Close();
                        }
                    }));
                }
                catch (Exception ex)
                {
                    LoadForm.HideLoading();
                    MessageBox.Show("连接失败!\n\r" + ex.Message);
                }
            });
        }
コード例 #15
0
 private void DeviceInfoForm_Load(object sender, EventArgs e)
 {
     LoadForm?.Invoke(sender, e);
 }
コード例 #16
0
ファイル: SQLForm.cs プロジェクト: yswenli/WEF
        public void RunSql()
        {
            var sql = AutoTextBox.TextBox.Text;

            stopwatch.Restart();

            LoadForm.ShowLoading(this);

            Task.Factory.StartNew(() =>
            {
                try
                {
                    WEF.DbDAL.IDbObject dbObject = DBObjectHelper.GetDBObject(ConnectionModel);

                    if (string.IsNullOrEmpty(sql))
                    {
                        LoadForm.HideLoading(this);;

                        this.Invoke(new Action(() =>
                        {
                            MessageBox.Show(this, "sql内容不能为空!");
                        }));

                        return;
                    }

                    this.Invoke(new Action(() =>
                    {
                        if (!string.IsNullOrWhiteSpace(AutoTextBox.TextBox.SelectedText))
                        {
                            sql = AutoTextBox.TextBox.SelectedText.Trim();

                            if (string.IsNullOrEmpty(sql))
                            {
                                LoadForm.HideLoading(this);;
                                MessageBox.Show(this, "sql内容不能为空!");
                                return;
                            }
                        }

                        dataGridView1.DataSource = null;
                    }));

                    if (sql.IndexOf("select", StringComparison.InvariantCultureIgnoreCase) >= 0)
                    {
                        try
                        {
                            int max = 50;

                            var ds = dbObject.Query(ConnectionModel.Database, sql);

                            if (ds != null && ds.Tables != null)
                            {
                                var dt = ds.Tables[0];

                                if (dt != null)
                                {
                                    var count = dt.Rows.Count;

                                    if (count > max)
                                    {
                                        for (int i = max; i < count; i++)
                                        {
                                            dt.Rows.RemoveAt(max);
                                        }
                                    }


                                    var dList = new List <int>();

                                    for (int i = 0; i < dt.Columns.Count; i++)
                                    {
                                        if (dt.Columns[i].DataType == typeof(DateTime))
                                        {
                                            dList.Add(i);
                                        }
                                    }


                                    dataGridView1.Invoke(new Action(() =>
                                    {
                                        dataGridView1.DataSource = dt;

                                        if (dList.Any())
                                        {
                                            foreach (var item in dList)
                                            {
                                                dataGridView1.Columns[item].DefaultCellStyle.Format = "yyyy-MM-dd HH:mm:ss.fff";
                                            }
                                        }

                                        lbl_execute.Text = $"当前显示{(max > count ? count : max)}行,影响数据行数:{count} 耗时:{stopwatch.Elapsed.TotalSeconds} 秒";
                                    }));
                                }
                            }
                            LoadForm.HideLoading(this);;
                        }
                        catch (Exception ex)
                        {
                            LoadForm.HideLoading(this);;
                            this.Invoke(new Action(() =>
                            {
                                MessageBox.Show(this, $"查询发生异常,ex:" + ex.Message);
                            }));
                        }
                    }
                    else
                    {
                        try
                        {
                            var count = dbObject.ExecuteSql(ConnectionModel.Database, sql);

                            lbl_execute.Invoke(new Action(() =>
                            {
                                lbl_execute.Text = $"影响数据行数:{count} 耗时:{stopwatch.Elapsed.TotalMilliseconds} 毫秒";
                            }));

                            LoadForm.HideLoading(this);;
                        }
                        catch (Exception ex)
                        {
                            LoadForm.HideLoading(this);;
                            this.Invoke(new Action(() =>
                            {
                                MessageBox.Show(this, $"操作发生异常,ex:" + ex.Message);
                            }));
                        }
                    }
                }
                catch (Exception ex)
                {
                    this.Invoke(new Action(() =>
                    {
                        MessageBox.Show(this, $"操作发生异常,ex:" + ex.Message);
                    }));
                }
            });
        }
コード例 #17
0
 public void Load()
 {
     LoadForm?.Invoke(this, new PowerThreadNodeLoadEventArgs());
 }
コード例 #18
0
 private void condition_2_txb_KeyPress(object sender, KeyPressEventArgs e)
 {
     LoadForm.LimitInput(sender, e, 1);
 }
コード例 #19
0
 //限制采购价格文本输入,不允许负数
 private void purchase_price_txb_KeyPress(object sender, KeyPressEventArgs e)
 {
     LoadForm.LimitInput(sender, e, 0);
 }
コード例 #20
0
 //限制联系方式(新增供应商时)文本输入,不允许负数
 private void tel_txb_KeyPress(object sender, KeyPressEventArgs e)
 {
     LoadForm.LimitInput(sender, e, 0);
 }
コード例 #21
0
 private void FmDepartmentView_Load(object sender, EventArgs e)
 {
     LoadForm?.Invoke(sender, e);
 }
コード例 #22
0
        private void btnFZTest_Click(object sender, EventArgs e)
        {
            LoadForm LForm = new LoadForm();

            LForm.ShowDialog();
        }
コード例 #23
0
 //限制充值金额控件输入,不允许负数
 private void charge_balance_txb_KeyPress(object sender, KeyPressEventArgs e)
 {
     LoadForm.LimitInput(sender, e, 0);
 }
コード例 #24
0
 public FrmMenu()
 {
     InitializeComponent();
     toolStripStatusLabelDate.Text = DateTime.Now.ToString("dd/MM/yyyy");
     lf += new LoadForm(OpenForm);
 }
コード例 #25
0
 private void Saucer_Load(object sender, EventArgs e)
 {
     LoadForm.centerForm(this);
     fillTable();
 }
コード例 #26
0
        /// <summary>
        /// 连接  测试
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            if (checkBox1.Checked)
            {
                if (string.IsNullOrEmpty(textBox1.Text))
                {
                    MessageBox.Show("连接字符串不能为空!");
                    return;
                }

                LoadForm.ShowLoading(this);

                WEF.DbDAL.IDbObject dbObejct = null;

                try
                {
                    dbObejct = new WEF.DbDAL.SQL2000.DbObject(textBox1.Text);
                }
                catch (Exception ex)
                {
                    LoadForm.HideLoading();
                    MessageBox.Show($"连接测试失败:{ex.Message}");
                }

                if (dbObejct == null)
                {
                    return;
                }

                cbbDatabase.Enabled = false;

                Task.Factory.StartNew(() =>
                {
                    try
                    {
                        var DBNameTable = dbObejct.GetDBList();

                        this.Invoke(new Action(() =>
                        {
                            cbbDatabase.Items.Clear();
                            cbbDatabase.Items.Add("全部");
                            foreach (DataRow dr in DBNameTable.Rows)
                            {
                                cbbDatabase.Items.Add(dr[0].ToString());
                            }

                            cbbDatabase.Enabled       = true;
                            cbbDatabase.SelectedIndex = 0;
                            LoadForm.HideLoading();
                            MessageBox.Show("连接成功!");

                            button2.Enabled = true;
                        }));
                    }
                    catch (Exception ex)
                    {
                        LoadForm.HideLoading();
                        MessageBox.Show("连接失败!\n\r" + ex.Message);
                    }
                });
            }
            else
            {
                if (string.IsNullOrEmpty(cbbServer.Text))
                {
                    MessageBox.Show("服务器不能为空!");
                    return;
                }

                if (cbbShenFenRZ.SelectedIndex == 1 && string.IsNullOrEmpty(txtUserName.Text))
                {
                    MessageBox.Show("登陆名不能为空!");
                    return;
                }


                LoadForm.ShowLoading(this);

                WEF.DbDAL.IDbObject dbObejct = new WEF.DbDAL.SQL2000.DbObject(cbbShenFenRZ.SelectedIndex == 0, cbbServer.Text, txtUserName.Text, txtPassword.Text);

                cbbDatabase.Enabled = false;

                Task.Factory.StartNew(() =>
                {
                    try
                    {
                        var DBNameTable = dbObejct.GetDBList();

                        this.Invoke(new Action(() =>
                        {
                            cbbDatabase.Items.Clear();
                            cbbDatabase.Items.Add("全部");
                            foreach (DataRow dr in DBNameTable.Rows)
                            {
                                cbbDatabase.Items.Add(dr[0].ToString());
                            }

                            cbbDatabase.Enabled       = true;
                            cbbDatabase.SelectedIndex = 0;
                            LoadForm.HideLoading();
                            MessageBox.Show("连接成功!");

                            button2.Enabled = true;
                        }));
                    }
                    catch (Exception ex)
                    {
                        LoadForm.HideLoading();
                        MessageBox.Show("连接失败!\n\r" + ex.Message);
                    }
                });
            }
        }