Example #1
0
        public static object Create(SessionInfo sessioninfo, MA_COUTERPARTY record)
        {
            try
            {
                CounterpartyBusiness _counterpartyBusiness = new CounterpartyBusiness();
                LookupBusiness _lookupBusiness = new LookupBusiness();
                MA_CTPY_LIMIT cplimit;

                record.ID = Guid.NewGuid();
                record.SNAME = record.SNAME.ToUpper();
                record.TBMA_NAME = record.TBMA_NAME.ToUpper();
                record.FNAME = record.FNAME.ToUpper();
                record.BUSINESS = record.BUSINESS.ToUpper();
                record.ISACTIVE = record.ISACTIVE == null || !record.ISACTIVE.Value ? false : true;
                record.LOG.INSERTDATE = DateTime.Now;
                record.LOG.INSERTBYUSERID = sessioninfo.CurrentUserId;
                record.GROUP_CTPY_ID = record.GROUP_CTPY_ID == Guid.Empty ? null : record.GROUP_CTPY_ID;

                //Prepare Counterparty-Limit data
                List<MA_LIMIT> limits = _lookupBusiness.GetLimitAll();

                foreach (MA_LIMIT limit in limits)
                {
                    cplimit = new MA_CTPY_LIMIT();

                    cplimit.ID = Guid.NewGuid();
                    cplimit.CTPY_ID = record.ID;
                    cplimit.LIMIT_ID = limit.ID;
                    cplimit.FLAG_CONTROL = true;
                    cplimit.AMOUNT = 0;
                    cplimit.EXPIRE_DATE = sessioninfo.Process.CurrentDate;
                    cplimit.LOG.INSERTDATE = DateTime.Now;
                    cplimit.LOG.INSERTBYUSERID = sessioninfo.CurrentUserId;

                    record.MA_CTPY_LIMIT.Add(cplimit);
                }

                var addedRecord = _counterpartyBusiness.Create(sessioninfo, record);

                addedRecord.MA_CTPY_LIMIT.Clear();

                return new { Result = "OK", Record = addedRecord };
            }
            catch (Exception ex)
            {
                return new { Result = "ERROR", Message = ex.Message };
            }
        }
 public static object Create(MA_COUTERPARTY record)
 {
     return CounterpartyUIP.Create(SessionInfo, record);
 }
Example #3
0
 public static object Update(SessionInfo sessioninfo, MA_COUTERPARTY record)
 {
     try
     {
         if (record.ID == record.GROUP_CTPY_ID) {
             throw new Exception("Group can't same as Counterparty.");
         }
         CounterpartyBusiness _counterpartyBusiness = new CounterpartyBusiness();
         record.SNAME = record.SNAME.ToUpper();
         record.TBMA_NAME = record.TBMA_NAME.ToUpper();
         record.FNAME = record.FNAME.ToUpper();
         record.BUSINESS = record.BUSINESS.ToUpper();
         record.ISACTIVE = record.ISACTIVE == null || !record.ISACTIVE.Value ? false : true;
         record.LOG.MODIFYBYUSERID = sessioninfo.CurrentUserId;
         record.LOG.MODIFYDATE = DateTime.Now;
         record.GROUP_CTPY_ID = record.GROUP_CTPY_ID == Guid.Empty ? null : record.GROUP_CTPY_ID;
         var addedRecord = _counterpartyBusiness.Update(sessioninfo, record);
         return new { Result = "OK", Record = addedRecord };
     }
     catch (Exception ex)
     {
         return new { Result = "ERROR", Message = ex.Message };
     }
 }