Ejemplo n.º 1
0
        private void UpdateStoreCountInfo(int index)
        {
            DataGridViewRow row = dataGridView1.Rows[index];

            DrugShop.Entities.Inventory count = row.DataBoundItem as DrugShop.Entities.Inventory;

            if (count == null)
            {
                return;
            }

            if (count.State == 1)
            {
                MessageBox.Show("盘点信息已进行过库存调整,无法编辑!", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            //弹出输入实际库存的对话框
            StoreCountNumberInput input = new StoreCountNumberInput();

            input.StoreNumber = count.Number;

            if (input.ShowDialog(this.ParentForm) != DialogResult.OK)
            {
                return;
            }

            //根据输入的实际值初始化相关的信息

            DrugShop.Entities.Inventory item = new Entities.Inventory();

            ColumnCollection cols = count.GetColumns();

            foreach (Property prop in cols)
            {
                if (item.ContainsProperty(prop.Name))
                {
                    item[prop.Name] = count[prop];
                }
            }

            item.RealNumber = input.Number;

            this.updateStoreCountList.Add(item);

            //重新绑定列表中的信息
            this.dmrcountBindingSource.DataSource = null;
            this.dmrcountBindingSource.DataSource = this.updateStoreCountList;
        }
Ejemplo n.º 2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (this.dataGridView1.Rows.Count <= 0)
            {
                MessageBox.Show("请先选择药品盘点数据!", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            DrugShop.Entities.Inventory count = ServiceContainer.GetService <IDrugStoreCountService>().GetDrugStoreCountList(Convert.ToDateTime(this.cbxDate.Text.Trim()));

            if (count == null)
            {
                return;
            }

            if (count.State > 0)
            {
                MessageBox.Show(this.cbxDate.Text + "盘存数据已经进行过库存调整,不能再次进行库存调整!", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (!ServiceContainer.GetService <IDrugStoreCountService>().IsNeedUpdate(Convert.ToDateTime(this.cbxDate.Text.Trim())))
            {
                MessageBox.Show(this.cbxDate.Text + "盘存数据不包含盈亏数据,不能进行库存调整!", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            this.Cursor = System.Windows.Forms.Cursors.WaitCursor;

            try
            {
                ServiceContainer.GetService <IDrugStoreCountService>().DrugStoreCountAdjust(this.storeCountList);
            }
            catch (System.Exception exc)
            {
                MessageBox.Show("在保存药品盘点时发生错误,错误信息:" + exc.Message, "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            finally
            {
                this.Cursor = System.Windows.Forms.Cursors.Default;
            }

            this.BindStoreCountDate();
            this.dmrcountBindingSource.DataSource = null;
        }