Ejemplo n.º 1
0
        /// <summary>
        /// 获取库存产品信息
        /// </summary>
        public void WarehouseProductInfo(HttpContext context)
        {
            var id = context.Request.QueryString["id"];

            if (!string.IsNullOrEmpty(id))
            {
                var thisWarePro = new ivt_warehouse_product_dal().FindNoDeleteById(long.Parse(id));
                if (thisWarePro != null)
                {
                    context.Response.Write(new Tools.Serialize().SerializeJson(thisWarePro));
                }
            }
        }
Ejemplo n.º 2
0
        public ERROR_CODE DeleteInventory(long id, long user_id)
        {
            var user = UserInfoBLL.GetUserInfo(user_id);

            if (user == null)
            {   // 查询不到用户,用户丢失
                return(ERROR_CODE.USER_NOT_FIND);
            }
            ivt_warehouse_product_dal inv_dal = new ivt_warehouse_product_dal();
            var inv = inv_dal.FindNoDeleteById(id);

            if (inv == null)
            {
                return(ERROR_CODE.ERROR);
            }
            inv.delete_user_id = user_id;
            inv.delete_time    = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
            if (!inv_dal.Update(inv))
            {
                return(ERROR_CODE.ERROR);
            }
            //操作日志
            var add_log = new sys_oper_log()
            {
                user_cate           = "用户",
                user_id             = (int)user.id,
                name                = user.name,
                phone               = user.mobile == null ? "" : user.mobile,
                oper_time           = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now),
                oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.WAREHOUSE_PRODUCT, //
                oper_object_id      = inv.id,                                   // 操作对象id
                oper_type_id        = (int)OPER_LOG_TYPE.DELETE,
                oper_description    = _dal.AddValue(inv),
                remark              = "删除产品库存信息"
            };                                      // 创建日志

            new sys_oper_log_dal().Insert(add_log); // 插入日志

            return(ERROR_CODE.SUCCESS);
        }
Ejemplo n.º 3
0
        /// <summary>
        ///新增产品库存信息
        /// </summary>
        /// <param name="stock"></param>
        /// <param name="user_id"></param>
        /// <returns></returns>
        public ERROR_CODE InsertProductStock(ivt_warehouse_product stock, long user_id)
        {
            var user = UserInfoBLL.GetUserInfo(user_id);

            if (user == null)
            {   // 查询不到用户,用户丢失
                return(ERROR_CODE.USER_NOT_FIND);
            }
            //唯一性校验
            ivt_warehouse_product_dal kk = new ivt_warehouse_product_dal();
            var re = kk.FindSignleBySql <ivt_warehouse_product>($"select * from ivt_warehouse_product where product_id={stock.product_id} and warehouse_id={stock.warehouse_id} and delete_time=0");

            if (re != null)
            {
                return(ERROR_CODE.EXIST);
            }
            stock.id             = (int)(_dal.GetNextIdCom());
            stock.create_time    = stock.update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
            stock.create_user_id = stock.update_user_id = user_id;
            kk.Insert(stock);
            //操作日志
            var add_log = new sys_oper_log()
            {
                user_cate           = "用户",
                user_id             = (int)user.id,
                name                = user.name,
                phone               = user.mobile == null ? "" : user.mobile,
                oper_time           = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now),
                oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.WAREHOUSE_PRODUCT, //
                oper_object_id      = stock.id,                                 // 操作对象id
                oper_type_id        = (int)OPER_LOG_TYPE.ADD,
                oper_description    = _dal.AddValue(stock),
                remark              = "新增产品库存信息"
            };                                      // 创建日志

            new sys_oper_log_dal().Insert(add_log); // 插入日志

            return(ERROR_CODE.SUCCESS);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 产品删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ERROR_CODE DeleteProduct(long id, long user_id, out string returnvalue)
        {
            returnvalue = string.Empty;
            var user = UserInfoBLL.GetUserInfo(user_id);

            if (user == null)
            {   // 查询不到用户,用户丢失
                return(ERROR_CODE.USER_NOT_FIND);
            }
            StringBuilder result = new StringBuilder();

            result.Append("产品不能被删除,因为它被以下对象引用\n");
            var opportunitylist       = new crm_opportunity_dal().FindListBySql($"select * from crm_opportunity where primary_product_id={id} and delete_time=0");
            var installed_productlist = new crm_installed_product_dal().FindListBySql($"select * from crm_installed_product where product_id={id} and delete_time=0");
            var warehouse_productlist = new ivt_warehouse_product_dal().FindListBySql($"select * from ivt_warehouse_product where product_id={id} and delete_time=0");
            var contract_costlist     = new ctt_contract_cost_dal().FindListBySql($"select * from ctt_contract_cost where product_id={id} and delete_time=0");
            int n = 1;

            if (opportunitylist.Count > 0)
            {
                result.Append($"{opportunitylist.Count} 商机\n");
                //foreach (var op in opportunitylist) {

                //    result.Append("N"+(n++)+"   "+op.id + "\n");
                //}
            }
            if (installed_productlist.Count > 0)
            {
                result.Append($"{installed_productlist.Count} 配置项\n");
                //foreach (var op in installed_productlist)
                //{
                //    result.Append("N" + (n++) + "  " + op.id + "\n");
                //}
            }
            if (warehouse_productlist.Count > 0)
            {
                result.Append($"{warehouse_productlist.Count} 库存\n");
                //foreach (var op in warehouse_productlist)
                //{
                //    result.Append("N" + (n++) + "  " + op.id + "\n");
                //}
            }
            if (contract_costlist.Count > 0)
            {
                result.Append($"{contract_costlist.Count} 工单\n");
                //foreach (var op in contract_costlist)
                //{
                //    result.Append("N" + (n++) + "  " + op.id + "\n");
                //}
            }
            if (contract_costlist.Count > 0 || warehouse_productlist.Count > 0 || installed_productlist.Count > 0 || opportunitylist.Count > 0)
            {
                returnvalue = result.ToString();
                return(ERROR_CODE.EXIST);
            }
            var product_del = _dal.FindSignleBySql <ivt_product>($"select * from ivt_product where id={id} and delete_time=0");

            if (product_del == null)
            {
                return(ERROR_CODE.ERROR);
            }
            product_del.delete_time    = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
            product_del.delete_user_id = user.id;
            if (!_dal.Update(product_del))
            {
                return(ERROR_CODE.ERROR);
            }
            //操作日志
            var add_log = new sys_oper_log()
            {
                user_cate           = "用户",
                user_id             = (int)user.id,
                name                = user.name,
                phone               = user.mobile == null ? "" : user.mobile,
                oper_time           = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now),
                oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.PRODUCT, //
                oper_object_id      = product_del.id,                 // 操作对象id
                oper_type_id        = (int)OPER_LOG_TYPE.DELETE,
                oper_description    = _dal.AddValue(product_del),
                remark              = "删除产品信息"
            };                                      // 创建日志

            new sys_oper_log_dal().Insert(add_log); // 插入日志


            var del = _dal.FindSignleBySql <ivt_product>($"select * from ivt_product where id={id} and delete_time=0");

            return(ERROR_CODE.SUCCESS);
        }