Esempio n. 1
0
        /// <summary>
        /// 编制人修改子表信息
        /// </summary>
        /// <param name="goods">扣货单明细信息</param>
        /// <param name="storageID">库房ID</param>
        /// <param name="error">出错时返回错误信息,无错时返回null</param>
        /// <returns>修改成功返回True,修改失败返回False</returns>
        public bool UpdateList(S_MaterialDetainList goods, string storageID, out string error)
        {
            try
            {
                error = null;

                DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext;

                var result = from r in dataContxt.S_MaterialDetainList
                             where r.ID == goods.ID
                             select r;

                if (result.Count() > 0)
                {
                    S_MaterialDetainList updateGoods = result.Single();

                    updateGoods.Bill_ID  = goods.Bill_ID;
                    updateGoods.GoodsID  = goods.GoodsID;
                    updateGoods.Provider = goods.Provider;
                    updateGoods.BatchNo  = goods.BatchNo;
                    updateGoods.Amount   = goods.Amount;
                    updateGoods.Remark   = goods.Remark;

                    dataContxt.SubmitChanges();
                }

                return(true);
            }
            catch (Exception exce)
            {
                error = exce.Message;
                return(false);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 采购员选择订单号,修改子表信息
        /// </summary>
        /// <param name="billID">单据号</param>
        /// <param name="goodsID">物品ID</param>
        /// <param name="orderFormID">关联订单号</param>
        /// <param name="batchNo">批次号</param>
        /// <param name="error">出错时返回错误信息,无错时返回null</param>
        /// <returns>成功返回True,否则返回False</returns>
        public bool UpdateList(string billID, string goodsID, string orderFormID, string batchNo, out string error)
        {
            error = "";

            try
            {
                DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext;

                var result = from a in dataContxt.S_MaterialDetainList
                             where a.Bill_ID == billID && a.GoodsID == Convert.ToInt32(goodsID) &&
                             a.BatchNo == batchNo
                             select a;

                if (result.Count() == 1)
                {
                    S_MaterialDetainList list = result.Single();

                    list.AssociateID = orderFormID;

                    dataContxt.SubmitChanges();

                    return(true);
                }
                else
                {
                    error = "数据错误,请核对后再操作!";
                    return(false);
                }
            }
            catch (Exception ex)
            {
                error = ex.Message;
                return(false);
            }
        }
Esempio n. 3
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (!CheckDataItem())
            {
                return;
            }

            S_MaterialDetainList goods = new S_MaterialDetainList();

            goods.Bill_ID  = m_strBillID;
            goods.GoodsID  = Convert.ToInt32(txtName.Tag.ToString());
            goods.Provider = txtProvider.Text;
            goods.BatchNo  = txtBatchNo.Text;
            goods.Amount   = numAmount.Value;
            goods.Remark   = txtRemark.Text;

            DataTable dvt = (DataTable)dataGridView1.DataSource;

            if (CheckSameGoods(dvt, goods))
            {
                if (!m_goodsServer.AddList(goods, out m_strErr))
                {
                    MessageDialog.ShowErrorMessage(m_strErr);
                    return;
                }
            }

            RefreshDataGridView(m_goodsServer.GetList(m_strBillID, out m_strErr));
            PositioningRecord(m_strBillID);
            ClearControl();
        }
Esempio n. 4
0
        /// <summary>
        /// 检查相同物品
        /// </summary>
        /// <param name="Dt">需要检测的数据集</param>
        /// <param name="goods">物品明细信息</param>
        /// <returns>不相同返回True,相同返回False</returns>
        bool CheckSameGoods(DataTable dt, S_MaterialDetainList goods)
        {
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (dt.Rows[i]["物品ID"].ToString() == goods.GoodsID.ToString() &&
                    dt.Rows[i]["批次号"].ToString() == goods.BatchNo.ToString())
                {
                    MessageBox.Show("不能添加同一个物品,请重新确认物品", "提示");
                    return(false);
                }
            }

            return(true);
        }
Esempio n. 5
0
        /// <summary>
        /// 添加子表信息
        /// </summary>
        /// <param name="list">子表数据集</param>
        /// <param name="error">出错时返回错误信息,无错时返回null</param>
        /// <returns>成功返回True,否则返回False</returns>
        public bool AddList(S_MaterialDetainList list, out string error)
        {
            error = "";

            try
            {
                DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext;

                dataContxt.S_MaterialDetainList.InsertOnSubmit(list);

                dataContxt.SubmitChanges();

                return(true);
            }
            catch (Exception ex)
            {
                error = ex.Message;
                return(false);
            }
        }
Esempio n. 6
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count == 0)
            {
                MessageDialog.ShowPromptMessage("请选择一条记录后再进行此操作");
                return;
            }

            if (dataGridView1.SelectedRows.Count > 1)
            {
                MessageDialog.ShowPromptMessage("只允许选择一条记录进行处理!");
                return;
            }

            if (BasicInfo.ListRoles.Contains(CE_RoleEnum.采购员.ToString()) && m_operateMode == CE_BusinessOperateMode.采购确认)
            {
                if (txtAssociateID.Text.Trim() != "")
                {
                    if (!m_goodsServer.UpdateList(m_strBillID, txtName.Tag.ToString(),
                                                  txtAssociateID.Text, txtBatchNo.Text.Trim(), out m_strErr))
                    {
                        MessageDialog.ShowErrorMessage(m_strErr);
                        return;
                    }
                }
                else
                {
                    MessageDialog.ShowPromptMessage("请选择关联订单号!");
                }
            }
            else if (m_strBillStatus.Equals("新建单据"))
            {
                S_MaterialDetainList      goods     = new S_MaterialDetainList();
                View_S_MaterialDetainList viewGoods = GetGoodsInfo(dataGridView1.SelectedRows[0]);

                goods.ID      = viewGoods.序号;
                goods.Bill_ID = m_strBillID;

                if (txtName.Tag != null && (int)txtName.Tag != 0)
                {
                    goods.GoodsID = (int)txtName.Tag;
                }
                else
                {
                    goods.GoodsID = viewGoods.物品ID;
                }

                goods.Provider = txtProvider.Text;
                goods.BatchNo  = txtBatchNo.Text;
                goods.Amount   = numAmount.Value;
                goods.Remark   = txtRemark.Text;

                if (!m_goodsServer.UpdateList(goods, m_strStorageID, out m_strErr))
                {
                    MessageDialog.ShowErrorMessage(m_strErr);
                    return;
                }
            }

            RefreshDataGridView(m_goodsServer.GetList(m_strBillID, out m_strErr));
            PositioningRecord(m_strBillID);
            ClearControl();
        }