Ejemplo n.º 1
0
        /// <summary>
        /// 查找物品
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnFindCode_Click(object sender, EventArgs e)
        {
            try
            {
                ClearControl();

                FormQueryInfo        form             = QueryInfoDialog.GetOrderFormGoodsDialog(m_billInfo.OrderBill_ID, true);
                IOrderFormInfoServer serviceOrderForm = ServerModuleFactory.GetServerModule <IOrderFormInfoServer>();
                View_B_OrderFormInfo orderInfo        = serviceOrderForm.GetOrderFormInfo(m_billInfo.OrderBill_ID);
                if (form != null && form.ShowDialog() == DialogResult.OK)
                {
                    txtCode.Text = (string)form.GetDataItem("图号型号");
                    txtName.Text = (string)form.GetDataItem("物品名称");
                    txtSpec.Text = (string)form.GetDataItem("规格");

                    IBargainGoodsServer serviceGoodsInfo = ServerModuleFactory.GetServerModule <IBargainGoodsServer>();
                    numUnitPrice.Value = serviceGoodsInfo.GetGoodsUnitPrice(m_billInfo.OrderBill_ID, Convert.ToInt32(form.GetDataItem("物品ID")), orderInfo.供货单位);

                    numGoodsAmount.Value = (decimal)form.GetDataItem("订货数量");

                    View_F_GoodsPlanCost planCost = GetBasicGoodsInfo(txtCode.Text, txtName.Text, txtSpec.Text, numUnitPrice.Value);

                    if (planCost != null)
                    {
                        cmbUnit.Text           = planCost.单位;
                        numPlanUnitPrice.Value = planCost.单价;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageDialog.ShowPromptMessage(ex.Message);
                return;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 删除合同信息
        /// </summary>
        /// <param name="bargainNumber">合同编号</param>
        /// <param name="returnBargainInfo">返回查询到的合同信息</param>
        /// <param name="error">错误信息, 没有则为null</param>
        /// <returns>操作是否成功的标志</returns>
        public bool DeleteBargainInfo(string bargainNumber, out IQueryResult returnBargainInfo, out string error)
        {
            error             = null;
            returnBargainInfo = null;

            try
            {
                DepotManagementDataContext       dataContxt  = CommentParameter.DepotDataContext;
                IBargainGoodsServer              goodsServer = ServerModuleFactory.GetServerModule <IBargainGoodsServer>();
                IQueryable <View_B_BargainGoods> returnBargainGoods;

                if (!goodsServer.GetBargainGoods(bargainNumber, out returnBargainGoods, out error))
                {
                    return(false);
                }

                #region 检查此合同的订单信息

                IOrderFormInfoServer orderFormServer = ServerModuleFactory.GetServerModule <IOrderFormInfoServer>();

                if (orderFormServer.GetOrderFormCollection(bargainNumber).Count() > 0)
                {
                    error = string.Format("合同 [{0}] 还包含有订单信息无法进行删除,请将所有此合同包含的订单信息全部删除后才能进行此操作!",
                                          bargainNumber);
                    return(false);
                }

                #endregion

                if (returnBargainGoods != null && returnBargainGoods.Count() > 0)
                {
                    error = string.Format("合同 [{0}] 还包含有零件信息无法进行删除,请将所有此合同包含的零件信息全部删除后才能进行此操作!",
                                          bargainNumber);
                    return(false);
                }

                Table <B_BargainInfo> table = dataContxt.GetTable <B_BargainInfo>();

                var delRow = from c in table
                             where c.BargainNumber == bargainNumber
                             select c;

                table.DeleteAllOnSubmit(delRow);
                dataContxt.SubmitChanges();

                return(GetAllBargainInfo(out returnBargainInfo, out error));
            }
            catch (Exception exce)
            {
                error = exce.Message;
                return(false);
            }
        }
        /// <summary>
        /// 获取订单物品表中某一产品单价
        /// </summary>
        /// <param name="orderFormNumber">订单物品号</param>
        /// <param name="goodsID">物品ID</param>
        /// <returns>返回获取到的单价</returns>
        public decimal GetGoodsUnitPrice(string orderFormNumber, int goodsID)
        {
            DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext;

            var result = from r in dataContxt.B_OrderFormInfo
                         where r.OrderFormNumber == orderFormNumber
                         select r;

            if (result.Count() == 0)
            {
                throw new Exception("找不到订单物品中对应的物品,无法获取物品单价!");
            }

            var varData = from a in dataContxt.B_OrderFormInfo
                          where a.OrderFormNumber == orderFormNumber
                          select a;

            IBargainGoodsServer bargainGoodsServer = ServerModuleFactory.GetServerModule <IBargainGoodsServer>();

            return(bargainGoodsServer.GetGoodsUnitPrice(result.Single().BargainNumber, goodsID, varData.Single().Provider));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 获取指定合同的物品信息对话框
        /// </summary>
        /// <param name="bargainNumber">合同号</param>
        /// <param name="simpleMode">是否是简单模式的标志, 是则只显示最基本的物品信息列(图号、名称、规格)</param>
        /// <returns>成功则返回获取到的对话框,失败返回null</returns>
        static public FormQueryInfo GetBargainGoodsDialog(string bargainNumber, bool simpleMode)
        {
            IBargainGoodsServer infoServer = ServerModuleFactory.GetServerModule <IBargainGoodsServer>();
            IQueryable <View_B_BargainGoods> queryResult;

            if (!infoServer.GetBargainGoods(bargainNumber, out queryResult, out m_err))
            {
                MessageDialog.ShowErrorMessage(m_err);
                return(null);
            }

            //FormQueryInfo form = new FormQueryInfo(queryInfo);
            System.Data.DataTable dataTable = GlobalObject.GeneralFunction.ConvertToDataTable <View_B_BargainGoods>(queryResult);
            FormQueryInfo         form      = new FormQueryInfo(dataTable);

            if (simpleMode)
            {
                form.ShowColumns = new string[] { "图号型号", "物品名称", "规格" };
            }

            return(form);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 修改合同信息
        /// </summary>
        /// <param name="oldBargainNumber">旧合同号</param>
        /// <param name="bargainInfo">合同信息</param>
        /// <param name="returnBargainInfo">返回查询到的合同信息</param>
        /// <param name="error">错误信息, 没有则为null</param>
        /// <returns>操作是否成功的标志</returns>
        public bool UpdateBargainInfo(string oldBargainNumber, B_BargainInfo bargainInfo,
                                      out IQueryResult returnBargainInfo, out string error)
        {
            returnBargainInfo = null;
            error             = null;

            try
            {
                DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext;

                var result = from r in dataContxt.B_BargainInfo
                             where r.BargainNumber == oldBargainNumber
                             select r;

                if (result.Count() == 0)
                {
                    error = string.Format("找不到合同号为 [{0}] 的信息!", oldBargainNumber);
                    return(false);
                }

                B_BargainInfo       record      = result.Single();
                IBargainGoodsServer goodsServer = ServerModuleFactory.GetServerModule <IBargainGoodsServer>();

                if (oldBargainNumber != bargainInfo.BargainNumber)
                {
                    IQueryable <View_B_BargainGoods> returnBargainGoods;

                    if (!goodsServer.GetBargainGoods(oldBargainNumber, out returnBargainGoods, out error))
                    {
                        return(false);
                    }

                    goodsServer.AutoSubmitToDatabase = false;

                    foreach (var item in returnBargainGoods)
                    {
                        if (!goodsServer.UpdateBargainNumber(dataContxt, item.序号, bargainInfo.BargainNumber, out error))
                        {
                            return(false);
                        }
                    }

                    #region 更新订单信息表中的合同编号

                    IOrderFormInfoServer orderFormServer = ServerModuleFactory.GetServerModule <IOrderFormInfoServer>();
                    orderFormServer.UpdateBargainNumber(dataContxt, oldBargainNumber, bargainInfo.BargainNumber);

                    #endregion

                    dataContxt.B_BargainInfo.DeleteOnSubmit(record);
                    record = new B_BargainInfo();
                }

                record.BargainNumber   = bargainInfo.BargainNumber;
                record.Provider        = bargainInfo.Provider;
                record.Buyer           = bargainInfo.Buyer;
                record.Cess            = bargainInfo.Cess;
                record.Date            = bargainInfo.Date;
                record.InputPerson     = bargainInfo.InputPerson;
                record.LaisonMode      = bargainInfo.LaisonMode;
                record.ProviderLinkman = bargainInfo.ProviderLinkman;
                record.IsOverseas      = bargainInfo.IsOverseas;
                record.IsConsignOut    = bargainInfo.IsConsignOut;
                record.Remark          = bargainInfo.Remark;
                record.AuditDate       = bargainInfo.AuditDate;

                if (oldBargainNumber != bargainInfo.BargainNumber)
                {
                    dataContxt.B_BargainInfo.InsertOnSubmit(record);
                }

                dataContxt.SubmitChanges();

                goodsServer.AutoSubmitToDatabase = true;

                return(GetAllBargainInfo(out returnBargainInfo, out error));
            }
            catch (Exception exce)
            {
                error = exce.Message;
                return(false);
            }
        }
Ejemplo n.º 6
0
        private void btnAutoGenerate_Click(object sender, EventArgs e)
        {
            if (dataGridView1.Rows.Count > 0)
            {
                MessageDialog.ShowPromptMessage("请删除此清单中的所有物品后再进行此操作!");
                return;
            }

            IOrderFormGoodsServer orderFormGoodsServer    = ServerModuleFactory.GetServerModule <IOrderFormGoodsServer>();
            IQueryable <View_B_OrderFormGoods> goodsGroup = null;

            if (!orderFormGoodsServer.GetOrderFormGoods(
                    BasicInfo.ListRoles, BasicInfo.LoginID, m_billInfo.OrderBill_ID, out goodsGroup, out m_error))
            {
                MessageDialog.ShowErrorMessage(m_error);
                return;
            }

            S_OrdinaryInDepotBill lnqBill          = m_serverBill.GetBill(m_billNo);
            IOrderFormInfoServer  serviceOrderForm = ServerModuleFactory.GetServerModule <IOrderFormInfoServer>();
            View_B_OrderFormInfo  orderInfo        = serviceOrderForm.GetOrderFormInfo(m_billInfo.OrderBill_ID);

            foreach (var item in goodsGroup)
            {
                if (item.订货数量 == 0)
                {
                    continue;
                }

                S_OrdinaryInDepotGoodsBill goods    = new S_OrdinaryInDepotGoodsBill();
                View_F_GoodsPlanCost       planCost = GetBasicGoodsInfo(item.图号型号, item.物品名称, item.规格, 0);

                if (planCost == null)
                {
                    return;
                }

                goods.GoodsID         = planCost.序号;
                goods.Bill_ID         = m_billNo;
                goods.ProviderBatchNo = "";

                if (m_serverGoodsShelfLife.IsShelfLife(planCost.序号))
                {
                    goods.BatchNo = m_goodsServer.GetNewBatchNo();
                }
                else
                {
                    goods.BatchNo = "";
                }

                goods.Amount = item.订货数量;

                IBargainGoodsServer serviceBargainGoods = ServerModuleFactory.GetServerModule <IBargainGoodsServer>();

                goods.UnitPrice     = serviceBargainGoods.GetGoodsUnitPrice(orderInfo.订单号, goods.GoodsID, orderInfo.供货单位);
                goods.Price         = decimal.Round(goods.UnitPrice * item.订货数量, (int)2);
                goods.AmountInWords = CalculateClass.GetTotalPrice(goods.Price);
                goods.Remark        = txtRemark.Text;

                if (!m_goodsServer.AddGoods(m_billNo, goods, out m_queryResult, out m_error))
                {
                    MessageDialog.ShowErrorMessage(m_error);
                    return;
                }
            }

            btnRefresh_Click(sender, e);
        }