Exemplo n.º 1
0
        //编辑物品
        private void EditData()
        {
            frmEditMaterial frmem = new frmEditMaterial();
            DataTable       tlbmaterialtype;

            tlbmaterialtype = rms_var.LoadMaterialType(cbStorageDept.Text);
            for (int i = 0; i <= tlbmaterialtype.Rows.Count - 1; i++)
            {
                frmem.ComboBox1.Items.Add(tlbmaterialtype.Rows[i]["Name"]);
            }
            frmem.frmMode             = 2;
            frmem.OldMaterialCode     = dgMaterial[dgMaterial.CurrentRowIndex, 0].ToString();
            frmem.OldMaterialName     = dgMaterial[dgMaterial.CurrentRowIndex, 1].ToString();
            frmem.TextBox1.Text       = dgMaterial[dgMaterial.CurrentRowIndex, 0].ToString();
            frmem.TextBox2.Text       = dgMaterial[dgMaterial.CurrentRowIndex, 1].ToString();
            frmem.TextBox3.Text       = dgMaterial[dgMaterial.CurrentRowIndex, 9].ToString();
            frmem.TextBox4.Text       = dgMaterial[dgMaterial.CurrentRowIndex, 2].ToString();
            frmem.TextBox5.Text       = dgMaterial[dgMaterial.CurrentRowIndex, 3].ToString();
            frmem.NumericUpDown1.Text = dgMaterial[dgMaterial.CurrentRowIndex, 11].ToString();
            frmem.NumericUpDown2.Text = dgMaterial[dgMaterial.CurrentRowIndex, 12].ToString();
            frmem.NumericUpDown3.Text = dgMaterial[dgMaterial.CurrentRowIndex, 10].ToString();
            frmem.ComboBox1.Text      = dgMaterial[dgMaterial.CurrentRowIndex, 5].ToString();
            frmem.Text = "编辑物品";
            frmem.CurrentStorageDeptName = cbStorageDept.Text;
            frmem.ShowDialog();
            if (frmem.DialogResult == DialogResult.OK)
            {
                LoadMaterials(cbStorageDept.Text);
            }
        }
Exemplo n.º 2
0
        private void ToolBar1_ButtonClick(System.Object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
        {
            switch (ToolBar1.Buttons.IndexOf(e.Button))
            {
            case 0:                     //添加数据
                try
                {
                    frmEditMaterial frmem_1 = new frmEditMaterial();
                    frmem_1.frmMode = 1;     //add
                    DataTable strgdept_1;
                    strgdept_1 = rms_var.LoadMaterialType(cbStorageDept.Text);
                    for (int i = 0; i <= strgdept_1.Rows.Count - 1; i++)
                    {
                        frmem_1.ComboBox1.Items.Add(strgdept_1.Rows[i]["Name"]);
                    }
                    frmem_1.ComboBox1.SelectedIndex = 0;
                    frmem_1.Text = "添加物品";
                    frmem_1.CurrentStorageDeptName = cbStorageDept.Text;
                    frmem_1.ShowDialog();
                    if (frmem_1.DialogResult == DialogResult.OK)
                    {
                        LoadMaterials(cbStorageDept.Text);
                    }
                }
                catch (Exception err)
                {
                    MessageBox.Show(err.Message);
                }
                break;

            case 1:                     //修改数据
                EditData();
                break;

            case 2:                     //删除当前数据
                if (MessageBox.Show("确定要删除当前选中的编号为 " + dgMaterial[dgMaterial.CurrentRowIndex, 0].ToString().Trim() + " 的物品类别吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                {
                    if (DelMaterial(dgMaterial[dgMaterial.CurrentRowIndex, 0].ToString()))
                    {
                        LoadMaterials(cbStorageDept.Text);
                    }
                }
                break;

            case 4:
                frmEditMaterial frmem = new frmEditMaterial();
                DataTable       strgdept;
                strgdept = rms_var.LoadMaterialType(cbStorageDept.Text);
                for (int i = 0; i <= strgdept.Rows.Count - 1; i++)
                {
                    frmem.ComboBox1.Items.Add(strgdept.Rows[i]["Name"]);
                }
                frmem.ComboBox1.SelectedIndex = 0;

                frmem.frmMode = 3;                         //查询数据
                frmem.Text    = "查询物品信息";

                frmem.ShowDialog();
                if (frmem.DialogResult == DialogResult.OK)
                {
                    SearchData(frmem.TextBox1.Text, frmem.TextBox2.Text, rms_var.GetMaterialTypeCode(frmem.ComboBox1.Text), frmem.TextBox3.Text);
                }
                break;

            case 6:
                if (MessageBox.Show("确定要进行打印操作吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                {
                    if (!PrintReport(CurrentMatrlLstSqlCode))
                    {
                        MessageBox.Show("打印失败!如果问题依然存在请联系系统管理员。");
                    }
                }
                break;

            case 8:
                this.Close();
                break;
            }
        }