Example #1
0
        /// <summary>
        /// 判断是否允许往订单中增加此物品
        /// </summary>
        /// <param name="operation">操作方式, 添加或更新</param>
        /// <param name="bargainNumber">合同号</param>
        /// <param name="goods">要增加或更新的物品信息</param>
        /// <param name="error">出错时返回错误信息,无错时返回null</param>
        /// <returns>允许返回true, 否则返回false</returns>
        private bool AllowGoods(string operation, string bargainNumber, B_OrderFormGoods goods, out string error)
        {
            IQueryable <View_B_OrderFormInfo> orderFormGroup = m_orderFormServer.GetOrderFormCollection(bargainNumber);

            error = null;

            IQueryable <View_B_OrderFormGoods> goodsGroup = m_serverOrderFormGoods.GetOrderFormGoods(bargainNumber);

            if (goodsGroup == null || goodsGroup.Count() == 0)
            {
                return(true);
            }

            List <View_B_OrderFormGoods> lstGoods   = goodsGroup.ToList();
            View_B_OrderFormGoods        findResult = lstGoods.Find(p => p.物品ID == goods.GoodsID);

            if (findResult == null)
            {
                return(true);
            }

            if (operation == "更新" && findResult.订单号 == goods.OrderFormNumber)
            {
                return(true);
            }

            error = string.Format("{0} 订单已经存在物品:{1},{2},{3},不允许再重复!",
                                  findResult.订单号, findResult.图号型号, findResult.物品名称, findResult.规格);

            return(false);
        }
Example #2
0
        /// <summary>
        /// 获取指定订单的物品信息对话框
        /// </summary>
        /// <param name="orderFormNumber">订单号</param>
        /// <param name="simpleMode">是否是简单模式的标志, 是则只显示最基本的物品信息列(图号、名称、规格)</param>
        /// <returns>成功则返回获取到的对话框,失败返回null</returns>
        static public FormQueryInfo GetOrderFormGoodsDialog(string orderFormNumber, bool simpleMode)
        {
            IOrderFormGoodsServer orderFormGoodsServer = ServerModuleFactory.GetServerModule <IOrderFormGoodsServer>();
            IQueryable <View_B_OrderFormGoods> queryResult;

            if (!orderFormGoodsServer.GetOrderFormGoods(BasicInfo.ListRoles, BasicInfo.LoginID, orderFormNumber, 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_OrderFormGoods>(queryResult);
            FormQueryInfo         form      = new FormQueryInfo(dataTable);

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

            return(form);
        }
Example #3
0
        /// <summary>
        /// 删除订单信息
        /// </summary>
        /// <param name="listRole">角色列表</param>
        /// <param name="loginName">登录名</param>
        /// <param name="orderFormNumber">订单编号</param>
        /// <param name="returnOrderFormInfo">返回查询到的订单信息</param>
        /// <param name="error">错误信息, 没有则为null</param>
        /// <returns>操作是否成功的标志</returns>
        public bool DeleteOrderFormInfo(List <string> listRole, string loginName, string orderFormNumber,
                                        out IQueryable <View_B_OrderFormInfo> returnOrderFormInfo, out string error)
        {
            error = null;
            returnOrderFormInfo = null;

            DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext;

            try
            {
                IOrderFormGoodsServer goodsServer = ServerModuleFactory.GetServerModule <IOrderFormGoodsServer>();
                IQueryable <View_B_OrderFormGoods> returnOrderFormGoods;

                if (!goodsServer.GetOrderFormGoods(listRole, loginName, orderFormNumber, out returnOrderFormGoods, out error))
                {
                    return(false);
                }

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

                Table <B_OrderFormInfo> table = dataContxt.GetTable <B_OrderFormInfo>();
                var delRow = from c in table where c.OrderFormNumber == orderFormNumber select c;

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

                return(GetAllOrderFormInfo(listRole, loginName, out returnOrderFormInfo, out error));
            }
            catch (Exception exce)
            {
                error = exce.Message;
                return(false);
            }
        }
Example #4
0
        /// <summary>
        /// 修改订单信息
        /// </summary>
        /// <param name="listRole">角色列表</param>
        /// <param name="loginName">登录名</param>
        /// <param name="oldOrderFormNumber">旧订单号</param>
        /// <param name="orderFormInfo">订单信息</param>
        /// <param name="returnOrderFormInfo">返回查询到的订单信息</param>
        /// <param name="error">错误信息, 没有则为null</param>
        /// <returns>操作是否成功的标志</returns>
        public bool UpdateOrderFormInfo(List <string> listRole, string loginName, string oldOrderFormNumber,
                                        B_OrderFormInfo orderFormInfo, out IQueryable <View_B_OrderFormInfo> returnOrderFormInfo, out string error)
        {
            returnOrderFormInfo = null;
            error = null;

            DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext;

            try
            {
                var result = from r in dataContxt.B_OrderFormInfo where r.OrderFormNumber == oldOrderFormNumber select r;

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

                B_OrderFormInfo record = result.Single();

                IOrderFormGoodsServer goodsServer = ServerModuleFactory.GetServerModule <IOrderFormGoodsServer>();

                if (oldOrderFormNumber != orderFormInfo.OrderFormNumber)
                {
                    IQueryable <View_B_OrderFormGoods> returnOrderFormGoods;

                    if (!goodsServer.GetOrderFormGoods(listRole, loginName, oldOrderFormNumber,
                                                       out returnOrderFormGoods, out error))
                    {
                        return(false);
                    }

                    goodsServer.AutoSubmitToDatabase = false;

                    foreach (var item in returnOrderFormGoods)
                    {
                        if (!goodsServer.UpdateOrderFormNumber(dataContxt, listRole, loginName, item.序号,
                                                               orderFormInfo.OrderFormNumber, out error))
                        {
                            return(false);
                        }
                    }

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

                record.OrderFormNumber = orderFormInfo.OrderFormNumber;
                record.Provider        = orderFormInfo.Provider;
                record.Buyer           = orderFormInfo.Buyer;
                record.BargainNumber   = orderFormInfo.BargainNumber;
                record.TypeID          = orderFormInfo.TypeID;
                record.InputPerson     = orderFormInfo.InputPerson;
                record.ProviderLinkman = orderFormInfo.ProviderLinkman;
                record.ProviderEmail   = orderFormInfo.ProviderEmail;
                record.ProviderPhone   = orderFormInfo.ProviderPhone;
                record.ProviderFax     = orderFormInfo.ProviderFax;
                record.Remark          = orderFormInfo.Remark;
                record.TypeID          = orderFormInfo.TypeID;
                record.CreateDate      = orderFormInfo.CreateDate;

                if (oldOrderFormNumber != orderFormInfo.OrderFormNumber)
                {
                    dataContxt.B_OrderFormInfo.InsertOnSubmit(record);
                }

                dataContxt.SubmitChanges();

                goodsServer.AutoSubmitToDatabase = true;

                return(GetAllOrderFormInfo(listRole, loginName, out returnOrderFormInfo, out error));
            }
            catch (Exception exce)
            {
                error = exce.Message;
                return(false);
            }
        }
Example #5
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);
        }