示例#1
0
        private void dataGridView1_CellEnter(object sender, DataGridViewCellEventArgs e)
        {
            if (dataGridView1.CurrentRow == null)
            {
                return;
            }
            else
            {
                txtGoodsCode.Tag   = dataGridView1.CurrentRow.Cells["GoodsID"].Value.ToString();
                txtGoodsCode.Text  = dataGridView1.CurrentRow.Cells["图号型号"].Value.ToString();
                txtGoodsName.Text  = dataGridView1.CurrentRow.Cells["物品名称"].Value.ToString();
                txtGoodsName.Tag   = dataGridView1.CurrentRow.Cells["账务库房ID"].Value.ToString();
                txtSpec.Text       = dataGridView1.CurrentRow.Cells["规格"].Value.ToString();
                numCount.Value     = Convert.ToDecimal(dataGridView1.CurrentRow.Cells["挂账数量"].Value);
                lbUnit.Text        = dataGridView1.CurrentRow.Cells["单位"].Value.ToString();
                txtListRemark.Text = dataGridView1.CurrentRow.Cells["备注"].Value.ToString();

                Out_Stock lnqStock = IntegrativeQuery.QuerySecStock(Convert.ToInt32(txtGoodsCode.Tag), txtReceiving.Tag.ToString(), txtGoodsName.Tag.ToString());

                lbStock.Text = Convert.ToDecimal(lnqStock == null ? 0 : lnqStock.StockQty).ToString();
            }
        }
        private void dataGridView1_CellEnter(object sender, DataGridViewCellEventArgs e)
        {
            if (dataGridView1.CurrentRow == null)
            {
                return;
            }
            else
            {
                numApplyCount.Maximum = 10000000000;

                txtGoodsCode.Tag       = dataGridView1.CurrentRow.Cells["物品ID"].Value.ToString();
                txtGoodsCode.Text      = dataGridView1.CurrentRow.Cells["图号型号"].Value.ToString();
                txtGoodsName.Text      = dataGridView1.CurrentRow.Cells["物品名称"].Value.ToString();
                txtGoodsName.Tag       = dataGridView1.CurrentRow.Cells["账务库房ID"].Value.ToString();
                txtSpec.Text           = dataGridView1.CurrentRow.Cells["规格"].Value.ToString();
                numApplyCount.Value    = Convert.ToDecimal(dataGridView1.CurrentRow.Cells["申请数量"].Value);
                numAuditingCount.Value = Convert.ToDecimal(dataGridView1.CurrentRow.Cells["审核数量"].Value);
                lbUnit.Text            = dataGridView1.CurrentRow.Cells["单位"].Value.ToString();
                txtListRemark.Text     = dataGridView1.CurrentRow.Cells["备注"].Value.ToString();

                Out_Stock lnqStock = IntegrativeQuery.QuerySecStock(Convert.ToInt32(txtGoodsCode.Tag),
                                                                    txtShipments.Tag.ToString(), txtGoodsName.Tag.ToString());

                if (lnqStock == null)
                {
                    numApplyCount.Maximum = 0;
                }
                else
                {
                    numApplyCount.Maximum = Convert.ToDecimal(lnqStock.StockQty);
                }


                lbStock.Text = numApplyCount.Maximum.ToString();
            }
        }
示例#3
0
        /// <summary>
        /// 操作库存
        /// </summary>
        /// <param name="dataContext">数据上下文</param>
        /// <param name="outDetail">业务明细数据集</param>
        /// <param name="error">错误信息</param>
        /// <returns>成功返回True,失败返回False</returns>
        public bool OperationStock(DepotManagementDataContext dataContext, Out_DetailAccount outDetail, out string error)
        {
            error = null;

            try
            {
                if (IntegrativeQuery.IsSalesStorage(outDetail.SecStorageID))
                {
                    return(true);
                }

                var varData = from a in dataContext.Out_Stock
                              where a.GoodsID == outDetail.GoodsID &&
                              a.SecStorageID == outDetail.SecStorageID &&
                              a.StorageID == outDetail.StorageID
                              select a;

                F_GoodsPlanCost lnqGoods = IntegrativeQuery.QueryGoodsInfo(Convert.ToInt32(outDetail.GoodsID));

                if (varData.Count() == 0)
                {
                    if (outDetail.OperationCount < 0)
                    {
                        error = "不能添加负数的库存记录" + "[" + lnqGoods.GoodsCode + "] [" + lnqGoods.GoodsName + "] [" + lnqGoods.Spec + "]";
                        return(false);
                    }
                    else
                    {
                        Out_Stock lnqStock = new Out_Stock();

                        lnqStock.GoodsID      = Convert.ToInt32(outDetail.GoodsID);
                        lnqStock.Remark       = outDetail.Remark;
                        lnqStock.SecStorageID = outDetail.SecStorageID;
                        lnqStock.StockQty     = Convert.ToDecimal(outDetail.OperationCount);
                        lnqStock.Date         = ServerTime.Time;
                        lnqStock.Personnel    = BasicInfo.LoginName;
                        lnqStock.StorageID    = outDetail.StorageID;

                        dataContext.Out_Stock.InsertOnSubmit(lnqStock);
                    }
                }
                else if (varData.Count() == 1)
                {
                    Out_Stock lnqStock = varData.Single();

                    decimal dcSum = Convert.ToDecimal(lnqStock.StockQty) + Convert.ToDecimal(outDetail.OperationCount);

                    if (dcSum < 0)
                    {
                        error = "不允许库存数量为负数" + "[" + lnqGoods.GoodsCode + "] [" + lnqGoods.GoodsName + "] [" + lnqGoods.Spec + "]";
                        return(false);
                    }
                    else
                    {
                        lnqStock.StockQty  = Convert.ToDecimal(lnqStock.StockQty) + Convert.ToDecimal(outDetail.OperationCount);
                        lnqStock.Date      = ServerTime.Time;
                        lnqStock.Personnel = BasicInfo.LoginName;
                    }
                }
                else
                {
                    error = "库存数据不唯一" + "[" + lnqGoods.GoodsCode + "] [" + lnqGoods.GoodsName + "] [" + lnqGoods.Spec + "]";
                    return(false);
                }

                return(true);
            }
            catch (Exception ex)
            {
                error = ex.Message;
                return(false);
            }
        }
示例#4
0
        /// <summary>
        /// 操作库存信息
        /// </summary>
        /// <param name="stockInfo">库存数据集</param>
        /// <param name="operationType">操作类型 添加,删除, 修改</param>
        /// <param name="error">错误信息</param>
        /// <returns>成功返回True,失败返回False</returns>
        public bool OperationStockInfo(Out_Stock stockInfo, string operationType, out string error)
        {
            error = null;

            try
            {
                DepotManagementDataContext dataContext = CommentParameter.DepotDataContext;

                var varData = from a in dataContext.Out_Stock
                              where a.GoodsID == stockInfo.GoodsID &&
                              a.SecStorageID == stockInfo.SecStorageID &&
                              a.StorageID == stockInfo.StorageID
                              select a;

                switch (operationType)
                {
                case "添加":

                    if (varData.Count() != 0)
                    {
                        error = "不能重复插入库存";
                        return(false);
                    }
                    else
                    {
                        dataContext.Out_Stock.InsertOnSubmit(stockInfo);
                    }

                    break;

                case "删除":

                    if (varData.Count() != 1)
                    {
                        error = "数据不唯一";
                        return(false);
                    }
                    else
                    {
                        dataContext.Out_Stock.DeleteAllOnSubmit(varData);
                    }

                    break;

                case "修改":

                    var dataUpdate = from a in dataContext.Out_Stock
                                     where a.ID == stockInfo.ID
                                     select a;

                    Out_Stock lnqStock = dataUpdate.Single();

                    lnqStock.Date         = stockInfo.Date;
                    lnqStock.GoodsID      = stockInfo.GoodsID;
                    lnqStock.Personnel    = BasicInfo.LoginName;
                    lnqStock.Remark       = stockInfo.Remark;
                    lnqStock.SecStorageID = stockInfo.SecStorageID;
                    lnqStock.StockQty     = stockInfo.StockQty;
                    lnqStock.StorageID    = stockInfo.StorageID;

                    break;

                default:
                    break;
                }

                dataContext.SubmitChanges();

                return(true);
            }
            catch (Exception ex)
            {
                error = ex.Message;
                return(false);
            }
        }