Example #1
0
        /// <summary>
        /// 根据报修行项编号返回报修单行项信息
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        //public AssRepairOrderRow GetRowByRowID(String ROID, String RPOROWID)
        //{
        //    return _AssRepairOrderRowRepository.GetByID(ROID, RPOROWID).AsNoTracking().FirstOrDefault();
        //}
        #endregion

        #region 操作
        /// <summary>
        /// 新增报修单
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public ReturnInfo AddAssRepairOrder(repairInPutDto entity)
        {
            ReturnInfo RInfo = new ReturnInfo();

            List <cmdb_repairlog> Rows = _AssRepairOrderRepository.GetByAssetId(entity.asset_id).ToList();

            if (Rows != null && Rows.Count > 0)
            {
                if (Rows[0].repair_status == "等待修")
                {
                    RInfo.IsSuccess = false;
                    RInfo.ErrorInfo = "该资产已经报修,请等待!";
                    return(RInfo);
                }
            }

            if (String.IsNullOrEmpty(entity.call_man))
            {
                throw new Exception("处理人不能为空");
            }
            if (String.IsNullOrEmpty(entity.call_date.ToString()))
            {
                throw new Exception("维修日期不能为空");
            }
            if (String.IsNullOrEmpty(entity.repair_content))
            {
                throw new Exception("维修内容不能为空");
            }

            //String MaxID = _AssRepairOrderRepository.GetMaxID();        //获取当前最大报修单编号
            //String NowID = Helper.GeneratePRID("W", MaxID);                //生成最新的报修单编号
            //entity.ROID = NowID;
            try
            {
                var assbo = Mapper.Map <repairInPutDto, cmdb_repairlog>(entity);
                //                public string find_man { get; set; }
                //public string call_man { get; set; }
                //public System.DateTime call_date { get; set; }
                //public string repair_man { get; set; }
                //public string repair_content { get; set; }
                //public string repair_status { get; set; }
                //public int asset_id { get; set; }
                _unitOfWork.RegisterNew(assbo);
                //AddAssRepairOrderRow(entity);

                bool result = _unitOfWork.Commit();
                RInfo.IsSuccess = result;
                RInfo.ErrorInfo = "创建成功!";
                return(RInfo);
            }
            catch (Exception ex)
            {
                _unitOfWork.Rollback();
                RInfo.IsSuccess = false;
                RInfo.ErrorInfo = ex.Message;
                return(RInfo);
            }
        }
Example #2
0
        /// <summary>
        /// 创建报修单
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSave_Press(object sender, EventArgs e)
        {
            try
            {
                if (String.IsNullOrEmpty(btnDealMan.Text))
                {
                    throw new Exception("报修人不能为空");
                }

                if (String.IsNullOrEmpty(txtrepairman.Text))
                {
                    throw new Exception("维修人不能为空");
                }

                if (String.IsNullOrEmpty(txtContent.Text))
                {
                    throw new Exception("维修内容不能为空!");
                }

                if (String.IsNullOrEmpty(txtNote.Text))
                {
                    throw new Exception("发现者不能为空");
                }

                if (String.IsNullOrEmpty(txtsns.Text))
                {
                    throw new Exception("维修资产SN号不能为空");
                }

                if (String.IsNullOrEmpty(SN))
                {
                    List <string> sn_list = autofacConfig.SettingService.GetAllSns();
                    if (!sn_list.Contains(txtsns.Text))
                    {
                        throw new Exception("不存在序列号为" + txtsns.Text + "的闲置资产");
                    }
                }


                AssetsOutputDto outputDto = autofacConfig.SettingService.GetAssetsBysn(txtsns.Text);

                repairInPutDto repairs = new repairInPutDto
                {
                    //id = 0,
                    find_man       = txtNote.Text,
                    call_man       = btnDealMan.Text,
                    call_date      = DatePicker.Value,
                    repair_man     = txtrepairman.Text,
                    repair_content = txtContent.Text,
                    repair_status  = "等待修",
                    asset_id       = outputDto.id
                };

                //List<AssRepairOrderRow> Data = new List<AssRepairOrderRow>();
                //if (ListAssetsSN.Rows.Count == 0) throw new Exception("维修行项不能为空!");
                //foreach (ListViewRow Row in ListAssetsSN.Rows)
                //{
                //    frmOrderCreateSNLayout Layout = Row.Control as frmOrderCreateSNLayout;
                //    AssetsOrderRow RowData = Layout.getData();
                //    AssRepairOrderRow assRow = new AssRepairOrderRow();

                //    assRow.IMAGE = RowData.IMAGE;
                //    assRow.ASSID = RowData.ASSID;
                //    assRow.WAITREPAIRQTY = RowData.QTY;
                //    assRow.SN = RowData.SN;
                //    assRow.LOCATIONID = RowData.LOCATIONID;
                //    assRow.STATUS = RowData.STATUS;
                //    assRow.CREATEDATE = DateTime.Now;
                //    Data.Add(assRow);
                //}
                //RepairData.Rows = Data;
                ReturnInfo r = autofacConfig.assRepairOrderService.AddAssRepairOrder(repairs);
                if (r.IsSuccess)
                {
                    ShowResult = ShowResult.Yes;
                    Form.Close();          //创建成功
                    Toast("创建维修单成功!");
                }
                else
                {
                    throw new Exception(r.ErrorInfo);
                }
            }
            catch (Exception ex)
            {
                Toast(ex.Message);
            }
        }