Пример #1
0
 private void comboBoxMaterialName_SelectedIndexChanged(object sender, EventArgs e)
 {
     // ��յ��ۺͽ��
     textBoxPrice.Text = string.Empty;
     textBoxCash.Text = string.Empty;
     // ����fill �����б�comboBoxMaterialLevel��ѡ��
     comboBoxMaterialLevel.Items.Clear();
     if(comboBoxMaterialName.SelectedIndex<0)
     {
         return;
     }
     if (tableMaterial != null)
     {
         for (int i = 0; i < tableMaterial.Count; i++)
         {
             if (((TableMaterial)tableMaterial[i]).name == comboBoxMaterialName.SelectedItem.ToString())
             {
                 ListItem mt = new ListItem();
                 mt.ID = ((TableMaterial)tableMaterial[i]).id.ToString();
                 mt.Name = ((TableMaterial)tableMaterial[i]).level;
                 comboBoxMaterialLevel.Items.Add(mt);
             }
         }
         comboBoxMaterialLevel.DisplayMember = "Name";
         comboBoxMaterialLevel.ValueMember = "ID";
     }
 }
Пример #2
0
        private void Init()
        {
            MySqlConnection conn = null;
            try
            {
                Reset();
                eraseTimer.Elapsed += new ElapsedEventHandler(eraseTimer_Elapsed);
                eraseTimer.Interval = 2500;

                string pastName = null;
                conn = MySqlConnHelper.GetMySqlConn(Properties.Settings.Default.DbConn);
                MySqlCommand cmd = conn.CreateCommand();
                cmd.CommandType = CommandType.Text;
                MySqlDataAdapter adapter = null;
                adapter = new MySqlDataAdapter();
                DataTable dt = null;
                conn.Open();

                #region ����Ա
                //adapter = new MySqlDataAdapter();
                cmd.CommandText = "select id, name from employee";
                adapter.SelectCommand = cmd;
                dt = new DataTable();
                adapter.Fill(dt);
                conn.Close();
                if (dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        ListItem mt = new ListItem();
                        mt.ID = dt.Rows[i]["id"].ToString();
                        mt.Name = string.Format("{0} -- {1}", dt.Rows[i]["name"].ToString(), mt.ID);
                        comboBoxOperator.Items.Add(mt);
                    }
                    comboBoxOperator.DisplayMember = "Name";
                    comboBoxOperator.ValueMember = "ID";
                }
                #endregion

                #region ԭ��
                cmd.CommandText = "select id, name, level, price from material order by name asc, level asc;";
                adapter.SelectCommand = cmd;
                dt = new DataTable();
                adapter.Fill(dt);
                conn.Close();
                if (dt.Rows.Count > 0)
                {
                    tableMaterial = new ArrayList();
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        TableMaterial tm = new TableMaterial();
                        tm.id = int.Parse(dt.Rows[i]["id"].ToString());
                        tm.name = dt.Rows[i]["name"].ToString();
                        tm.level = dt.Rows[i]["level"].ToString();
                        tableMaterial.Add(tm);

                        if (pastName != tm.name)
                        {
                            comboBoxMaterialName.Items.Add(tm.name);
                        }
                        pastName = tm.name;
                    }
                }
                #endregion

                #region ����
                //adapter = new MySqlDataAdapter();
                cmd.CommandText = "select id, name, level, price from product order by name asc, level asc;";
                adapter.SelectCommand = cmd;
                dt = new DataTable();
                adapter.Fill(dt);
                conn.Close();
                if (dt.Rows.Count > 0)
                {
                    tableProduct = new ArrayList();
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        TableMaterial tm = new TableMaterial();
                        tm.id = int.Parse(dt.Rows[i]["id"].ToString());
                        tm.name = dt.Rows[i]["name"].ToString();
                        tm.level = dt.Rows[i]["level"].ToString();
                        tableProduct.Add(tm);

                        if (pastName != tm.name)
                        {
                            comboBoxProductName.Items.Add(tm.name);
                        }
                        pastName = tm.name;
                    }
                }
                #endregion
            }
            catch (MySqlException sqlEx)
            {
                WriteLog(sqlEx.ToString());
                NotifyHelper.NotifyUser("�޷����ӷ�����");
            }
            catch (Exception ex)
            {
                WriteLog(ex.ToString());
                NotifyHelper.NotifyUser("��ȡ����ʧ��");
            }
            finally
            {
                if (conn != null)
                {
                    conn.Close();
                }
            }
        }
Пример #3
0
        private void RefreshPurPerList()
        {
            listViewPurPerInfo.Items.Clear();
            MySqlConnection conn = null;
            try
            {
                conn = MySqlConnHelper.GetMySqlConn(Properties.Settings.Default.DbConn);
                MySqlDataAdapter adapter = new MySqlDataAdapter();
                MySqlCommand cmd = conn.CreateCommand();
                cmd.CommandType = CommandType.Text;
                cmd.CommandText = @"select t.id, t.name, t.ni, t.upper, t.tag, t.upper_used,
            t.org_id, s.name as org_name
            from  pur_customer t, pur_organization s
            where t.org_id=s.id order by t.name asc;";
                adapter.SelectCommand = cmd;
                DataTable dt = new DataTable();
                conn.Open();
                adapter.Fill(dt);
                conn.Close();
                if (dt.Rows.Count > 0)
                {

                    listViewPurPerInfo.BeginUpdate();
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        ListViewItem item = new ListViewItem(dt.Rows[i]["id"].ToString());
                        item.SubItems.Add(dt.Rows[i]["name"].ToString());
                        item.SubItems.Add(dt.Rows[i]["org_name"].ToString());
                        item.SubItems.Add(dt.Rows[i]["ni"].ToString());
                        item.SubItems.Add(dt.Rows[i]["upper"].ToString());
                        item.SubItems.Add(dt.Rows[i]["org_id"].ToString());    //5
                        item.SubItems.Add(dt.Rows[i]["tag"].ToString());    //6
                        item.SubItems.Add(dt.Rows[i]["upper_used"].ToString());    //7

                        listViewPurPerInfo.Items.Add(item);
                    }
                    listViewPurPerInfo.EndUpdate();
                }
                #region pur_organazition
                // �򻯴����߼���ÿ��ˢ��ʱ��ˢ��tableOrg��
                // ��ȻЧ�ʲ�����ã�������ά���dz���--������ģ�����֮���޹���
                // if (tableOrg == null)    // ֻ����һ��
                {
                    cmd.CommandText = "select id, name from pur_organization order by name asc";
                    adapter.SelectCommand = cmd;
                    dt.Clear();
                    conn.Open();
                    adapter.Fill(dt);
                    conn.Close();
                    if (dt.Rows.Count > 0)
                    {
                        tableOrg = new ArrayList();
                        comboBoxPurOrg.Items.Clear();
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            TableMaterial tm = new TableMaterial();
                            tm.id = int.Parse(dt.Rows[i]["id"].ToString());
                            tm.name = dt.Rows[i]["name"].ToString();
                            tableOrg.Add(tm);

                            ListItem org = new ListItem(tm.id.ToString(), tm.name);
                            comboBoxPurOrg.Items.Add(org);
                        }
                        comboBoxPurOrg.DisplayMember = "Name";
                        comboBoxPurOrg.ValueMember = "ID";
                    }
                }
                #endregion

            }
            catch (Exception ex)
            {
                WriteLog(ex.ToString());
                NotifyHelper.NotifyUser("����ʧ��: " + ex.Message);
            }
            finally
            {
                if (conn != null)
                {
                    conn.Close();
                }
            }
        }
Пример #4
0
 private void comboBoxProductName_SelectedIndexChanged(object sender, EventArgs e)
 {
     comboBoxProductLevel.Items.Clear();
     if (comboBoxProductName.SelectedIndex < 0)
     {
         return;
     }
     if (tableProduct != null)
     {
         for (int i = 0; i < tableProduct.Count; i++)
         {
             if (((TableMaterial)tableProduct[i]).name == comboBoxProductName.SelectedItem.ToString())
             {
                 ListItem mt = new ListItem();
                 mt.ID = ((TableMaterial)tableProduct[i]).id.ToString();
                 mt.Name = ((TableMaterial)tableProduct[i]).level;
                 comboBoxProductLevel.Items.Add(mt);
             }
         }
         comboBoxProductLevel.DisplayMember = "Name";
         comboBoxProductLevel.ValueMember = "ID";
     }
 }