Example #1
0
        /// <summary>
        /// 修改课程
        /// </summary>
        /// <param name="ht">参数Key:Id</param>
        /// <returns></returns>
        public JsonModel UpdateEquip(Hashtable ht)
        {
            try
            {
                EmsModel.EquipDetail model = dal.GetEmsModel(Convert.ToInt32(ht["ID"].ToString()));
                //model.EquipKindId = 0;//设备分类
                //model.AssetNumber = ht["AssetNumber"].ToString();//资产号
                //model.EquipIntoID = 0;//设备入库ID
                //model.EquipStatus = 0;//设备状态
                model.Type = Convert.ToByte(ht["Type"].ToString());              //类型 0教学资产;1科研资产;2办公资产
                //model.Barcode = DateTime.Now.ToString("yyMMddhhmmssffff");//条形码
                model.ImageName       = Convert.ToString(ht["ImageName"]);       //图片
                model.ImageUrl        = Convert.ToString(ht["ImageUrl"]);        //图片路径
                model.ClassNumber     = Convert.ToString(ht["ClassNumber"]);     //分类号
                model.AssetsClassName = Convert.ToString(ht["AssetsClassName"]); //资产分类名称
                model.IntlClassCode   = Convert.ToString(ht["IntlClassCode"]);   //国际分类代码
                model.IntlClassName   = Convert.ToString(ht["IntlClassName"]);   //国际分类名称
                model.AssetName       = Convert.ToString(ht["AssetName"]);       //资产名称
                model.Unit            = Convert.ToString(ht["Unit"]);            //单位
                //model.UsageStatus = ht["UsageStatus"].ToString();//使用状况
                model.UsageDirection = Convert.ToString(ht["UsageDirection"]);   //使用方向
                //model.JYBBBSYFX = ht["JYBBBSYFX"].ToString();//教育部报表使用方向
                //model.AcquisitionMethod = ht["AcquisitionMethod"].ToString();//取得方式
                //model.AcquisitionDate = Convert.ToDateTime(ht["AcquisitionDate"].ToString());//取得日期
                model.BrandStandardModel = Convert.ToString(ht["BrandStandardModel"]); //品牌及规格型号
                model.Remarks            = Convert.ToString(ht["Remarks"]);            //备注
                //model.Creator = ht["Creator"].ToString();//创建人
                //model.CreateTime = DateTime.Now;//创建时间
                model.Editor     = Convert.ToString(ht["UserIDCard"]); //修改人
                model.UpdateTime = DateTime.Now;                       //修改时间
                //model.IsDelete = 0;//是否删除
                //model.EquipSource = 0;//0本院资产;1资产系统
                //model.IsConsume = 0;//非耗材
                //model.Count = 1;//数量
                model.ManualModify = 1;//是否手动修改 0未修改 1修改

                int result = dal.Update(model);

                //定义JSON标准格式实体中
                JsonModel jsonModel = new JsonModel();
                if (result > 0)
                {
                    jsonModel.Status = "ok";
                    jsonModel.Msg    = "修改成功";
                }
                else
                {
                    jsonModel.Status = "no";
                    jsonModel.Msg    = "修改失败";
                }
                return(jsonModel);
            }
            catch (Exception ex)
            {
                JsonModel jsonModel = new JsonModel();
                jsonModel.Status = "error";
                jsonModel.Msg    = ex.ToString();
                return(jsonModel);
            }
        }
        public JsonModel SetRoomDistributionEquip(string roomid, string type, string equipids, string owneridcard)
        {
            //定义JSON标准格式实体中
            JsonModel jsonModel = new JsonModel();

            try
            {
                //事务
                using (SqlTransaction trans = dal.GetTran())
                {
                    try
                    {
                        if (!string.IsNullOrEmpty(equipids))
                        {
                            string[]           idArray   = equipids.Split(',');
                            int                count     = 0;
                            EmsDAL.EquipDetail dal_equip = new EmsDAL.EquipDetail();
                            foreach (string equipid in idArray)
                            {
                                EmsModel.EquipDetail equip = dal_equip.GetEmsModel(Convert.ToInt32(equipid));
                                equip.StorageLocation = roomid;
                                if (type == "2")
                                {
                                    equip.EquipOwner = owneridcard;
                                }
                                int result = dal_equip.Update(trans, equip);
                                if (result > 0)
                                {
                                    count++;
                                }
                            }
                            if (idArray.Length != count)
                            {
                                trans.Rollback();//回滚
                                jsonModel.Status = "no";
                                jsonModel.Msg    = "操作失败";
                                return(jsonModel);
                            }
                        }
                        trans.Commit();//提交
                    }
                    catch (Exception)
                    {
                        trans.Rollback();//回滚
                        throw;
                    }
                }
                jsonModel.Status = "ok";
                jsonModel.Msg    = "操作成功";
                return(jsonModel);
            }
            catch (Exception ex)
            {
                jsonModel.Status = "error";
                jsonModel.Msg    = ex.ToString();
                return(jsonModel);
            }
        }
Example #3
0
        /// <summary>
        /// 耗材入库
        /// </summary>
        /// <param name="equip">仪器设备对象</param>
        /// <returns></returns>
        public JsonModel EquipIntoCount(EmsModel.EquipDetail equip, int newCount)
        {
            //定义JSON标准格式实体中
            JsonModel jsonModel = new JsonModel();

            try
            {
                //事务
                using (SqlTransaction trans = dal.GetTran())
                {
                    try
                    {
                        EmsModel.EquipInto into = new EmsModel.EquipInto();
                        into.EquipKindId = equip.Id;
                        into.WarehouseId = 0;
                        into.Count       = newCount;
                        into.Creator     = equip.Editor;
                        into.CreateTime  = DateTime.Now;
                        into.IsDelete    = 0;
                        int result = dal.Update(trans, equip);//修改仪器设备数量
                        if (result == 0)
                        {
                            trans.Rollback();//回滚
                            jsonModel.Status = "no";
                            jsonModel.Msg    = "保存失败";
                            return(jsonModel);
                        }
                        result = new EmsDAL.EquipInto().Add(trans, into);
                        if (result == 0)
                        {
                            trans.Rollback();//回滚
                            jsonModel.Status = "no";
                            jsonModel.Msg    = "保存失败";
                            return(jsonModel);
                        }
                        else
                        {
                            trans.Commit();//提交
                        }
                    }
                    catch (Exception)
                    {
                        trans.Rollback();//回滚
                        throw;
                    }
                }
                jsonModel.Status = "ok";
                jsonModel.Msg    = "操作成功";
                return(jsonModel);
            }
            catch (Exception ex)
            {
                jsonModel.Status = "error";
                jsonModel.Msg    = ex.ToString();
                return(jsonModel);
            }
        }
Example #4
0
 /// <summary>
 /// 获得设备信息
 /// </summary>
 /// <param name="ht"></param>
 /// <returns></returns>
 public JsonModel GetEquip(Hashtable ht)
 {
     try
     {
         EmsModel.EquipDetail model = dal.GetEmsModel(Convert.ToInt32(ht["Id"].ToString()));
         //定义JSON标准格式实体中
         JsonModel jsonModel = null;
         if (model == null)
         {
             jsonModel = new JsonModel()
             {
                 Status = "no",
                 Msg    = ""
             };
             return(jsonModel);
         }
         else
         {
             //将分页数据实体封装到JSON标准实体中
             jsonModel = new JsonModel()
             {
                 Data    = model,
                 Msg     = "",
                 Status  = "ok",
                 BackUrl = ""
             };
             return(jsonModel);
         }
     }
     catch (Exception ex)
     {
         JsonModel jsonModel = new JsonModel();
         jsonModel.Status = "error";
         jsonModel.Msg    = ex.ToString();
         return(jsonModel);
     }
 }
Example #5
0
        /// <summary>
        /// 保存房间盘点信息
        /// </summary>
        /// <param name="invenid">盘点单id</param>
        /// <param name="roomid">房间id</param>
        /// <param name="idStr">盘点详情id</param>
        /// <param name="editStr">需要换房间的盘点详情id</param>
        /// <param name="useridcard">用户身份证号</param>
        /// <returns></returns>
        public JsonModel SaveRoomInventory(string invenid, string roomid, string idStr, string editStr, string useridcard)
        {
            //定义JSON标准格式实体中
            JsonModel jsonModel = new JsonModel();

            try
            {
                //事务
                using (SqlTransaction trans = dal.GetTran())
                {
                    try
                    {
                        string[] idArray   = idStr.Split(',');
                        string[] editArray = editStr.Split(',');
                        int      result    = 0;
                        if (!string.IsNullOrEmpty(idStr))
                        {
                            int idcount = 0;
                            foreach (string deid in idArray)
                            {
                                EmsModel.InventoryListDetail ind = dal.GetEmsModel(Convert.ToInt32(deid));
                                ind.IsLoss = true;
                                result     = dal.Update(trans, ind);
                                if (result > 0)
                                {
                                    idcount++;
                                }
                            }
                            if (idArray.Length != idcount)
                            {
                                trans.Rollback();//回滚
                                jsonModel.Status = "no";
                                jsonModel.Msg    = "保存失败";
                                return(jsonModel);
                            }
                        }
                        if (!string.IsNullOrEmpty(editStr))
                        {
                            int editcount = 0;
                            foreach (string editid in editArray)
                            {
                                EmsModel.InventoryListDetail ind = dal.GetEmsModel(Convert.ToInt32(editid));
                                ind.SourceRoomId = ind.RoomId;
                                ind.RoomId       = Convert.ToInt32(roomid);
                                ind.IsLoss       = true;
                                result           = dal.Update(trans, ind);
                                EmsDAL.EquipDetail   dal_equip = new EmsDAL.EquipDetail();
                                EmsModel.EquipDetail equip     = dal_equip.GetEmsModel(ind.EquipId);
                                equip.StorageLocation = roomid;
                                dal_equip.Update(trans, equip);//修改仪器设备详情存放地点
                                if (result > 0)
                                {
                                    editcount++;
                                }
                            }
                            if (editArray.Length != editcount)
                            {
                                trans.Rollback();//回滚
                                jsonModel.Status = "no";
                                jsonModel.Msg    = "保存失败";
                                return(jsonModel);
                            }
                        }
                        EmsDAL.InventoryList   dal_list = new EmsDAL.InventoryList();
                        EmsModel.InventoryList list     = dal_list.GetEmsModelByInvRoomId(invenid, roomid);
                        list.RealQuantity = (!string.IsNullOrEmpty(idStr) ? idArray.Length : 0) + (!string.IsNullOrEmpty(editStr) ? editArray.Length : 0);
                        list.Status       = 1;
                        list.Operator     = useridcard;
                        list.Editor       = useridcard;
                        list.UpdateTime   = DateTime.Now;
                        result            = dal_list.Update(trans, list);
                        if (result == 0)
                        {
                            trans.Rollback();//回滚
                            jsonModel.Status = "no";
                            jsonModel.Msg    = "保存失败";
                            return(jsonModel);
                        }
                        if (dal.GetNotInventoryCount(trans, invenid) == 0)
                        {
                            EmsDAL.InventoryPlan   dal_plan = new EmsDAL.InventoryPlan();
                            EmsModel.InventoryPlan plan     = dal_plan.GetEmsModel(Convert.ToInt32(invenid));
                            plan.Status = 1;
                            result      = dal_plan.Update(trans, plan);
                            if (result == 0)
                            {
                                trans.Rollback();//回滚
                                jsonModel.Status = "no";
                                jsonModel.Msg    = "保存失败";
                                return(jsonModel);
                            }
                        }
                        trans.Commit();//提交
                    }
                    catch (Exception)
                    {
                        trans.Rollback();//回滚
                        throw;
                    }
                }
                jsonModel.Status = "ok";
                jsonModel.Msg    = "操作成功";
                return(jsonModel);
            }
            catch (Exception ex)
            {
                jsonModel.Status = "error";
                jsonModel.Msg    = ex.ToString();
                return(jsonModel);
            }
        }
Example #6
0
        /// <summary>
        /// 读取Excel导入数据--设备
        /// </summary>
        /// <param name="ht">参数</param>
        /// <returns></returns>
        public JsonModel ImportEquip(Hashtable ht)
        {
            try
            {
                DataTable dt = common.ExcelToDataTable(ht["FilePath"].ToString());

                int           Yse = 0;
                int           No  = 0;
                StringBuilder sb  = new StringBuilder();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    DataRow dr = dt.Rows[i];
                    try
                    {
                        if (string.IsNullOrWhiteSpace(dr["资产编号"].ToString().Trim()) && string.IsNullOrWhiteSpace(dr["资产名称"].ToString().Trim()))
                        {
                            continue;
                        }
                        EmsModel.EquipDetail model = new EmsModel.EquipDetail();

                        Hashtable htCunZai = new Hashtable();
                        htCunZai.Add("AssetNumber", dr["资产编号"].ToString().Trim());
                        bool CunZai = dal.IsExists(htCunZai);
                        if (CunZai)
                        {
                            continue;
                        }
                        model.EquipKindId = 0;                            //设备分类Id
                        model.AssetNumber = dr["资产编号"].ToString().Trim(); //资产编号
                        model.EquipIntoID = 0;                            //设备入库ID
                        model.EquipStatus = 0;                            //设备状态 0  未借出 ; 1 已借出;2 维修;3 停用;4 报废
                        if (dr["资产类别"].ToString().Trim() == "教学设备")
                        {
                            model.Type = 0;//类型 0教学设备;1科研设备;2办公设备
                        }
                        else if (dr["资产类别"].ToString().Trim() == "科研设备")
                        {
                            model.Type = 1;//类型 0教学设备;1科研设备;2办公设备
                        }
                        else if (dr["资产类别"].ToString().Trim() == "办公设备")
                        {
                            model.Type = 2;//类型 0教学设备;1科研设备;2办公设备
                        }
                        else
                        {
                            model.Type = 0;//类型 0教学设备;1科研设备;2办公设备
                        }
                        if (dr["是否耗材"].ToString().Trim() == "非耗材")
                        {
                            model.IsConsume = 0;//0 非耗材;1 耗材;
                        }
                        else if (dr["是否耗材"].ToString().Trim() == "耗材")
                        {
                            model.IsConsume = 1;//0 非耗材;1 耗材;
                        }
                        else
                        {
                            model.IsConsume = 0;//0 非耗材;1 耗材;
                        }

                        model.EquipSource       = 1;                              //资产来源 0本院资产;1资产系统;
                        model.Barcode           = model.AssetNumber;              //条形码
                        model.ImageName         = "";                             //图片
                        model.Count             = 1;                              //数量
                        model.ClassNumber       = dr["资产分类代码"].ToString().Trim(); //分类号
                        model.AssetsClassName   = dr["资产分类名称"].ToString().Trim(); //资产分类名称
                        model.IntlClassCode     = "";                             //国标分类代码
                        model.IntlClassName     = dr["国标分类名称"].ToString().Trim(); //国标分类名称
                        model.AssetName         = dr["资产名称"].ToString().Trim();   //资产名称
                        model.Unit              = dr["计量单位"].ToString().Trim();   //计量单位
                        model.UsageStatus       = dr["使用状况"].ToString().Trim();   //使用状况
                        model.UsageDirection    = dr["使用方向"].ToString().Trim();   //使用方向
                        model.JYBBBSYFX         = dr["教育使用方向"].ToString().Trim(); //教育部报表使用方向
                        model.AcquisitionMethod = dr["取得方式"].ToString().Trim();   //取得方式
                        if (common.IsDateTime(dr["取得日期"].ToString().Trim()))
                        {
                            model.AcquisitionDate = Convert.ToDateTime(dr["取得日期"].ToString().Trim()); //取得日期
                        }
                        model.BrandStandardModel = dr["规格型号"].ToString().Trim();                      //品牌及规格型号
                        model.EquipmentUse       = dr["设备用途"].ToString().Trim();                      //设备用途
                        model.UseDepartment      = dr["使用/管理部门"].ToString().Trim();                   //使用/管理部门
                        model.UsePeople          = dr["使用人"].ToString().Trim();                       //使用人
                        model.Factory            = dr["厂家"].ToString().Trim();                        //厂家
                        model.StorageLocation    = "0";                                               //存放地点
                        model.WorthType          = dr["价值类型"].ToString().Trim();                      //价值类型
                        model.UseNature          = dr["使用性质"].ToString().Trim();                      //使用性质
                        if (common.IsDecimal(dr["价值"].ToString().Trim()))
                        {
                            model.Worth = Convert.ToDecimal(dr["价值"].ToString().Trim()); //价值
                        }
                        model.FinanceRecordType = dr["入账形式"].ToString().Trim();          //财务入账形式
                        if (common.IsDecimal(dr["财政性资金"].ToString().Trim()))
                        {
                            model.FiscalFunds = Convert.ToDecimal(dr["财政性资金"].ToString().Trim());//财政性资金
                        }
                        if (common.IsDecimal(dr["非财政性资金"].ToString().Trim()))
                        {
                            model.NonFiscalFunds = Convert.ToDecimal(dr["非财政性资金"].ToString().Trim());//非财政性资金
                        }
                        if (common.IsDateTime(dr["财务入账日期"].ToString().Trim()))
                        {
                            model.FinanceRecordDate = Convert.ToDateTime(dr["财务入账日期"].ToString().Trim()); //财务入账日期
                        }
                        model.VoucherNumber = dr["凭证号"].ToString().Trim();                                //凭证号
                        if (common.IsInt(dr["预计使用年限/寿命/种龄"].ToString().Trim()))
                        {
                            model.UseTime = Convert.ToInt32(dr["预计使用年限/寿命/种龄"].ToString().Trim());//使用年限(月)
                        }
                        //model.ExpectedScrapDate = Convert.ToDateTime(dr["资产编号"].ToString().Trim());//预计报废时间
                        model.DepreciationState = "";                             //折旧状态
                        model.NetWorth          = 0;                              //净值
                        model.OutFactoryNumber  = dr["出厂号"].ToString().Trim();    //出厂号
                        model.Supplier          = dr["供货商"].ToString().Trim();    //供货商
                        model.FundsSubject      = dr["经费科目"].ToString().Trim();   //经费科目
                        model.PurchaseModality  = dr["采购组织形式"].ToString().Trim(); //采购组织形式
                        model.CountryCode       = dr["国别码"].ToString().Trim();    //国别码
                        model.Operator          = dr["经办人"].ToString().Trim();    //经手人
                        if (common.IsDateTime(dr["保修截止日期"].ToString().Trim()))
                        {
                            model.GuaranteeEndDate = Convert.ToDateTime(dr["保修截止日期"].ToString().Trim()); //保修截止日期
                        }
                        model.EquipmentNumber = dr["设备号"].ToString().Trim();                             //设备号
                        model.InvoiceNumber   = dr["发票号"].ToString().Trim();                             //发票号
                        model.CompactNumber   = dr["合同号"].ToString().Trim();                             //合同号
                        model.BasicFunds      = "";                                                      //基本经费
                        model.ItemFunds1      = dr["项目经费1"].ToString().Trim();                           //项目经费1
                        model.ItemFunds2      = "";                                                      //项目经费2
                        model.ItemFunds3      = "";                                                      //项目经费3
                        model.ItemFunds4      = "";                                                      //项目经费4
                        if (common.IsDecimal(dr["保修截止日期"].ToString().Trim()))
                        {
                            model.ItemFundsMoney1 = Convert.ToDecimal(dr["项目经费1金额"].ToString().Trim()); //项目经费1金额
                        }
                        model.ItemFundsMoney2  = 0;                                                     //项目经费2金额
                        model.ItemFundsMoney3  = 0;                                                     //项目经费3金额
                        model.ItemFundsMoney4  = 0;                                                     //项目经费4金额
                        model.Remarks          = dr["备注"].ToString().Trim();                            //备注
                        model.Creator          = ht["Creator"].ToString();                              //创建人
                        model.CreateTime       = DateTime.Now;                                          //创建时间
                        model.IsDelete         = 0;                                                     //是否删除
                        model.UseStatus        = Convert.ToByte(ht["UseStatus"].ToString());            //使用状态
                        model.StorageLocation1 = dr["存放地点"].ToString().Trim();                          //存放地点


                        int Id = dal.Add(model);
                        if (Id > 0)
                        {
                            Yse++;
                        }
                        else
                        {
                            No++;
                            sb.Append((i + 2).ToString() + ",");
                        }
                    }
                    catch (Exception)
                    {
                        No++;
                        sb.Append((i + 2).ToString() + ",");
                    }
                }

                JsonModel jsonModel = new JsonModel();
                jsonModel.Status = "ok";
                //jsonModel.Msg = "成功" + Yse + "条,失败" + No + "条,共" + dt.Rows.Count + "条";
                jsonModel.Msg = "成功" + Yse + "条,失败" + No + "条";
                if (sb.Length != 0)
                {
                    jsonModel.Msg += "\n失败数据行号:" + sb.ToString();
                }
                return(jsonModel);
            }
            catch (Exception ex)
            {
                JsonModel jsonModel = new JsonModel();
                jsonModel.Status = "error";
                jsonModel.Msg    = ex.ToString();
                return(jsonModel);
            }
        }