private void Button1_Click(System.Object sender, System.EventArgs e)
        {
            bool successful = true;
            int  totalnum;

            totalnum = InventoryMaterials.Rows.Count - 1;

            for (int i = 0; i <= totalnum; i++)
            {
                if (InventoryMaterials.Rows[InventoryMaterials.Rows.Count - 1][0].ToString() == "")
                {
                    InventoryMaterials.Rows.RemoveAt(InventoryMaterials.Rows.Count - 1);
                    totalnum--;
                }
            }

            //检测盘存数量是否合法
            try
            {
                for (int i = 0; i <= InventoryMaterials.Rows.Count - 1; i++)
                {
                    if (System.Convert.ToDouble(DataGrid1[i, 3]) > System.Convert.ToDouble(DataGrid1[i, 4]))
                    {
                        MessageBox.Show("盘存数量不合法");
                        successful = false;
                        goto endOfTry;
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("盘存数量不合法");
                successful = false;
            }
endOfTry:

            if (successful)
            {
                this.DialogResult = DialogResult.OK;
                frmDeptInventory frmdi = new frmDeptInventory();
                frmdi.lblStorage.Text      = StorageDeptName;
                frmdi.lblDeptname.Text     = DeptName;
                frmdi.DateTimePicker1.Text = (DateTime.Parse(InventoryDate)).Year.ToString() + "-" + (DateTime.Parse(InventoryDate)).Month.ToString() + "-" + (DateTime.Parse(InventoryDate)).Day.ToString();
                frmdi.DateTimePicker2.Text = (DateTime.Parse(InventoryDate)).Hour.ToString() + ":" + (DateTime.Parse(InventoryDate)).Minute.ToString() + ":" + (DateTime.Parse(InventoryDate)).Second.ToString();
                if (DataGrid1.VisibleRowCount > 0)
                {
                    frmdi.SelectedMaterials      = InventoryMaterials;
                    frmdi.dgMaterials.DataSource = frmdi.SelectedMaterials;
                }
                frmdi.ShowDialog();
            }
        }
Esempio n. 2
0
        private void Button1_Click(System.Object sender, System.EventArgs e)
        {
            bool successful = true;
            int totalnum;
            totalnum = InventoryMaterials.Rows.Count - 1;

            for (int i = 0; i <= totalnum; i++)
            {
                if (InventoryMaterials.Rows[InventoryMaterials.Rows.Count - 1][0].ToString() == "")
                {
                    InventoryMaterials.Rows.RemoveAt(InventoryMaterials.Rows.Count - 1);
                    totalnum--;
                }
            }

            //检测盘存数量是否合法
            try
            {
                for (int i = 0; i <= InventoryMaterials.Rows.Count - 1; i++)
                {
                    if (System.Convert.ToDouble(DataGrid1[i, 3]) > System.Convert.ToDouble(DataGrid1[i, 4]))
                    {
                        MessageBox.Show("盘存数量不合法");
                        successful = false;
                        goto endOfTry;
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("盘存数量不合法");
                successful = false;
            }
            endOfTry:

            if (successful)
            {
                this.DialogResult = DialogResult.OK;
                frmDeptInventory frmdi = new frmDeptInventory();
                frmdi.lblStorage.Text = StorageDeptName;
                frmdi.lblDeptname.Text = DeptName;
                frmdi.DateTimePicker1.Text = (DateTime.Parse(InventoryDate)).Year.ToString() + "-" + (DateTime.Parse(InventoryDate)).Month.ToString() + "-" + (DateTime.Parse(InventoryDate)).Day.ToString();
                frmdi.DateTimePicker2.Text = (DateTime.Parse(InventoryDate)).Hour.ToString() + ":" + (DateTime.Parse(InventoryDate)).Minute.ToString() + ":" + (DateTime.Parse(InventoryDate)).Second.ToString();
                if (DataGrid1.VisibleRowCount > 0)
                {
                    frmdi.SelectedMaterials = InventoryMaterials;
                    frmdi.dgMaterials.DataSource = frmdi.SelectedMaterials;
                }
                frmdi.ShowDialog();
            }
        }