예제 #1
0
        /// <summary>
        /// 添加信息
        /// </summary>
        /// <param name="logistic">LINQ数据</param>
        /// <param name="error">错误信息</param>
        /// <returns>成功返回True,失败返回False</returns>
        public bool AddInfo(S_LogisticSafeStock logistic, out string error)
        {
            error = null;

            try
            {
                DepotManagementDataContext ctx = CommentParameter.DepotDataContext;

                var varData = from a in ctx.S_LogisticSafeStock
                              where a.GoodsID == logistic.GoodsID
                              select a;

                if (varData.Count() != 0)
                {
                    error = "数据重复";
                    return(false);
                }
                else
                {
                    ctx.S_LogisticSafeStock.InsertOnSubmit(logistic);
                    ctx.SubmitChanges();
                }

                return(true);
            }
            catch (Exception ex)
            {
                error = ex.Message;
                return(false);
            }
        }
        /// <summary>
        /// 获得信息
        /// </summary>
        void GetMessage()
        {
            m_lnqLogistc = new S_LogisticSafeStock();

            m_lnqLogistc.GoodsID  = Convert.ToInt32(tbsGoods.Tag);
            m_lnqLogistc.MaxValue = numMaxValue.Value;
            m_lnqLogistc.MinValue = numMinValue.Value;
            m_lnqLogistc.Remark   = txtRemark.Text;
        }
예제 #3
0
        /// <summary>
        /// 更新信息
        /// </summary>
        /// <param name="updateGoodsID">旧物品ID</param>
        /// <param name="logistic">LINQ信息</param>
        /// <param name="error">错误信息</param>
        /// <returns>成功返回True,失败返回False</returns>
        public bool UpdateInfo(int updateGoodsID, S_LogisticSafeStock logistic, out string error)
        {
            error = null;

            try
            {
                DepotManagementDataContext ctx = CommentParameter.DepotDataContext;

                var varData = from a in ctx.S_LogisticSafeStock
                              where a.GoodsID == updateGoodsID
                              select a;

                if (varData.Count() != 1)
                {
                    error = "数据不唯一";
                    return(false);
                }
                else
                {
                    S_LogisticSafeStock lnqLogistic = varData.Single();

                    lnqLogistic.GoodsID  = logistic.GoodsID;
                    lnqLogistic.MaxValue = logistic.MaxValue;
                    lnqLogistic.MinValue = logistic.MinValue;
                    lnqLogistic.Remark   = logistic.Remark;

                    ctx.SubmitChanges();
                }

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