Example #1
0
        public int AddErrand(ErrandVoucher errand, ref string errMsg)
        {
            ccode = voucherService.GetNewCode("TM02", "CC");
            List <ErrandVoucherBody> bodyList = errand.body;

            errand.head.cVoucherId          = ccode;
            errand.head.cVoucherCode        = ccode;
            errand.head.cCode               = "TM140";
            errand.head.cExamineApproveType = 2;
            errand.head.cStatus             = "0";
            errand.head.pk_hr_tm_ErrandMain = Guid.NewGuid().ToString();
            errand.head.dCreateOn           = DateTime.Now.ToString("yyyy-MM-dd HH:mm:dd");
            errand.head.vReason             = bodyList[0].vReason;
            errand.head.dBeginDate          = bodyList[0].dBeginDate;
            errand.head.dEndDate            = bodyList[0].dEndDate;
            for (int q = 0; q < bodyList.Count; q++)
            {
                string       person = bodyList[q].cPsn_Num;
                HRPersonInfo info   = voucherService.getPersonInfo(person, ref errMsg);
                bodyList[q].cDepCode = info.depCode;
                bodyList[q].cDepName = info.depName;
                errand.head.cDepName = info.depName;
                errand.head.cDepCode = info.depCode;
                bodyList[q].cCreator = errand.head.cCreateBy;
                //bodyList[q].pk_hr_tm_Errand = Guid.NewGuid().ToString();
                bodyList[q].cVoucherId          = ccode;
                bodyList[q].cExamineApproveType = "2";
                bodyList[q].cSysBarCode         = "|" + q.ToString();
                bodyList[q].bAuditFlag          = false;
                bodyList[q].cStatus             = "0";
                bodyList[q].cErrandType         = errand.head.cErrandType;
            }
            string headSql = errandService.getHeadSql(errand.head);
            int    a       = voucherService.excuteSql(headSql);
            string bodySql = errandService.getBodySql(errand.body);
            int    b       = 0;

            if (a == 1)
            {
                b = voucherService.excuteSql(bodySql);
            }
            if (b >= 1)
            {
                voucherService.UpdateMaxCode("TM02");
            }

            int i = a + b;

            return(i);
        }
Example #2
0
        public HttpResponseMessage AddErrand(string token, string json)
        {
            string        errMsg = "";
            ReturnMessage msg    = new ReturnMessage();

            try
            {
                ReceiveLog receive = new ReceiveLog();
                receive.uuid          = Guid.NewGuid();
                receive.receiveData   = json;
                receive.interfaceCode = "Errand";
                receive.interfaceDesc = "出差单新增";
                receive.op            = "add";

                vouMag = (VoucherManager)HttpContext.Current.Application.Get(token);
                if (vouMag == null)
                {
                    msg.Success = false;
                    msg.Msg     = "参数token无效或已过期";
                    msg.Code    = 500;
                }
                else
                {
                    ReceiveLogManager logManager = new ReceiveLogManager(vouMag.UFDataConnstringForNet);
                    logManager.AddReceiveLog(receive, ref errMsg);
                    ErrandManager errandMag = new ErrandManager(vouMag.UFDataConnstringForNet);
                    ErrandVoucher errand    = (ErrandVoucher)JsonConvert.DeserializeObject(json, typeof(ErrandVoucher));
                    int           i         = errandMag.AddErrand(errand, ref errMsg);
                    if (i >= 2)
                    {
                        //msg.Success = true;
                        //dynamic c = new { code = errandMag.ccode };
                        //msg.Data = JsonConvert.SerializeObject(c);
                        //msg.Code = 200;
                        //msg.Msg = "新增成功";
                        int q = errandMag.auditErrand(errandMag.ccode, errand.head, ref errMsg);
                        if (q >= 2)
                        {
                            msg.Success = true;
                            msg.Code    = 200;
                            dynamic c = new { code = errandMag.ccode };
                            msg.Data = JsonConvert.SerializeObject(c);
                            msg.Msg  = "审核成功";
                        }
                        else
                        {
                            msg.Success = false;
                            msg.Code    = 500;
                            msg.Msg     = "审核失败:" + errMsg;
                        }
                    }
                    else
                    {
                        msg.Success = false;
                        msg.Code    = 500;
                        msg.Msg     = "新增失败" + errMsg;
                    }
                    receive = logManager.getReturnDesc(receive, msg);
                    logManager.UpdateReceiveLog(receive, ref errMsg);
                }



                HttpContext.Current.Application.Remove(vouMag.GetGUID);
                string str = msg.ToJson();
                return(new HttpResponseMessage {
                    Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json")
                });
            }
            catch (Exception ex)
            {
                msg.Success = false;
                msg.Code    = 500;
                msg.Msg     = ex.Message.ToString();
                string str = msg.ToJson();
                return(new HttpResponseMessage {
                    Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json")
                });
            }
        }