Example #1
0
        /// <summary>
        /// 移除生产计划
        /// </summary>
        /// <param name="scjh"></param>
        public static void RemoveScjh(YK_ZJJG_JH jh, RelationalDatabase db, int jgbm)
        {
            //移除原料消耗明细-取消原料消耗出库-移除计划明细表数据

            try
            {
                #region 移除计划
                List <YK_ZJJG_JH> lstjh_check = YK_ZJJG_JH.GetJhList(string.Format(" and a.id='{0}' ", jh.id), "", db);
                if (lstjh_check.Count <= 0)
                {
                    throw new Exception("移除失败!找不到该计划,请刷新数据后重试!");
                }
                else
                {
                    YK_ZJJG_JH jh_check = lstjh_check[0];
                    if (jh_check.bshbz == 1)
                    {
                        throw new Exception("移除失败!该计划已经审核,不能移除!请先取消审核计划");
                    }
                    if (jh_check.bscbz == 1)
                    {
                        throw new Exception("移除失败!该计划已经被删除,请刷新数据!");
                    }
                }

                YK_ZJJG_JH.DeleteJh(db, jh.id, false);
                #endregion

                //#region 移除计划明细
                //YK_ZJJG_JHMX.DeleteJhmxByJhid(jh.id, db);
                //#endregion

                //#region 移除原料
                //YK_ZJJG_YLMX.DeleteYlmxByDjid(jh.id,db);
                //#endregion

                #region 更新库存
                //反向单据明细
                int    upt_err_code = 0;
                string upt_err_text = "";
                Yk_dj_djmx.UpdateKcDrt(jh.ckdjid, db);
                Yk_dj_djmx.AddUpdateKcmx(jh.ckdjid, out upt_err_code, out upt_err_text, Convert.ToInt64(jgbm), db);
                if (upt_err_code != 0)
                {
                    throw new Exception(upt_err_text.ToString());
                }
                Yk_dj_djmx.UpdateKcDrt(jh.ckdjid, db);
                #endregion

                #region  移除原料消耗入库单据
                Yk_dj_djmx.DeleteDj(jh.ckdjid, db);
                #endregion
            }
            catch (Exception err)
            {
                throw err;
            }
        }
Example #2
0
        /// <summary>
        /// 取消审核生产计划
        /// </summary>
        /// <param name="scjh"></param>
        public static void UnShScJh(YK_ZJJG_JH jh, RelationalDatabase db, int jgbm)
        {
            //更新计划明细-更新原料消耗明细-取消加工入库

            try
            {
                List <YK_ZJJG_JH> lstjh_check = YK_ZJJG_JH.GetJhList(string.Format(" and a.id='{0}' ", jh.id), "", db);
                if (lstjh_check.Count <= 0)
                {
                    throw new Exception("取消审核失败!找不到该计划,请刷新数据后重试!");
                }
                else
                {
                    YK_ZJJG_JH jh_check = lstjh_check[0];
                    if (jh_check.bshbz != 1)
                    {
                        throw new Exception("取消审核失败!请刷新数据后重试!");
                    }
                    if (jh_check.bscbz == 1)
                    {
                        throw new Exception("取消审核失败!该计划已经被删除,请刷新数据!");
                    }
                }

                #region 更新计划
                if (jh.bshbz != 1)
                {
                    throw new Exception("该计划还未审核,不能进行取消审核");
                }
                jh.bshbz = 0;
                YK_ZJJG_JH.SaveJh(db, jh, 1);
                #endregion

                #region 更新计划明细

                #endregion

                #region 更新原料消耗明细

                #endregion

                #region 更新库存
                int    upt_err_code = 0;
                string upt_err_text = "";
                Yk_dj_djmx.UpdateKcDrt(jh.rkdjid, db);
                Yk_dj_djmx.AddUpdateKcmx(jh.rkdjid, out upt_err_code, out upt_err_text, Convert.ToInt64(jgbm), db);
                if (upt_err_code != 0)
                {
                    throw new Exception(upt_err_text.ToString());
                }
                Yk_dj_djmx.UpdateKcDrt(jh.rkdjid, db);
                #endregion

                #region   除加工入库单
                Yk_dj_djmx.DeleteDj(jh.rkdjid, db);
                #endregion
            }
            catch (Exception err)
            {
                throw err;
            }
        }