Exemplo n.º 1
0
        public void ToMonthsTest()
        {
            var o      = new Operate(2);
            var result = o.ToMonths();

            Assert.That(result, Is.EqualTo(12), "期望值不相等");//定义消息
        }
Exemplo n.º 2
0
        public Operate calcFileSizeByM(Operate op)
        {
            if (null == op || Defined.OperateType.CalcFileSizeByMBs != op.type)
            {
                return(null);
            }

            FileInfo fi = null;

            try
            {
                fi = new FileInfo(op.value);
            }
            catch (Exception)
            {
                return(null);
            }

            if (null == fi)
            {
                return(null);
            }

            Operate newOp = new Operate();

            newOp.type  = Defined.OperateType.ReplaceWord;
            newOp.key   = op.key;
            newOp.value = string.Format("{0:N2} {1}",
                                        ((double)fi.Length) / 1024 / 1024, mWin.FindResource("million_bytes_unit"));
            return(newOp);
        }
Exemplo n.º 3
0
 public static void Save(Data.Operation oper, string dest)
 {
     var dat = new Operate();
     dat.Index = oper.Index;
     dat.RewindArray = oper.GetRewindStack();
     List<Operate.DestData> dd = new List<Operate.DestData>();
     foreach (var d in oper.Data.GetDestinationsKeys())
     {
         dd.Add(new Operate.DestData() { LinkKey = d, Dest = oper.Data.GetDestination(d).DestPath });
     }
     dat.DestArray = dd.ToArray();
     List<Operate.Element> el = new List<Operate.Element>();
     foreach (var e in oper.Data.GetElementsArray())
     {
         var ds = from ar in e.Destinations
                  select ar.Destination;
         el.Add(new Operate.Element() { Dest = ds.ToArray<string>(), Source = e.ImageSourcePath, DistributionMode = e.DistributionMode });
     }
     dat.ElementArray = el.ToArray();
     var bf = new BinaryFormatter();
     using (FileStream fs = new FileStream(dest, FileMode.Create, FileAccess.ReadWrite))
     {
         bf.Serialize(fs, dat);
     }
 }
Exemplo n.º 4
0
        public async Task <Operate> addBulkAddress(DeliveryAddrBulkModel model, string userName)
        {
            var result = new Operate();

            try
            {
                using (var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
                {
                    var deliveryAddrs = new List <DeliveryAddress>();
                    foreach (var item in model.DeliveryAddrModel)
                    {
                        DeliveryAddress deliveryAddr;
                        deliveryAddr            = item.ToDeliveryAddrModel();
                        deliveryAddr.CreateTime = DateTime.UtcNow;
                        deliveryAddr.CreateBy   = userName;
                        deliveryAddrs.Add(deliveryAddr);
                    }
                    await _deliveryAddrRepository.AddBulkAddress(deliveryAddrs);

                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                result.Status  = -1;
                result.Message = ex.Message;
                Logger.WriteErrorLog("DeliveryAddrService", "AddOrUpdate", ex);
            }
            return(result);
        }
Exemplo n.º 5
0
        public Operate calcFileModifiedTime(Operate op)
        {
            if (null == op || Defined.OperateType.CalcFileModifiedTime != op.type)
            {
                return(null);
            }

            FileInfo fi = null;

            try
            {
                fi = new FileInfo(op.value);
            }
            catch (Exception)
            {
                return(null);
            }

            if (null == fi)
            {
                return(null);
            }

            Operate newOp = new Operate();

            newOp.type  = Defined.OperateType.ReplaceWord;
            newOp.key   = op.key;
            newOp.value = string.Format("{0:yyyy-MM-dd HH:mm}", fi.LastWriteTime);
            return(newOp);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Delete addr model
        /// NOTE: soft delete
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task <Operate> DeleteById(int id)
        {
            var result = new Operate();

            try
            {
                using (var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
                {
                    var addr = await _deliveryAddrRepository.GetById(id);

                    if (addr == null)
                    {
                        result.Status  = -2;
                        result.Message = "This address does not exist";
                        return(result);
                    }

                    await _deliveryAddrRepository.Delete(addr);

                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                result.Status  = -1;
                result.Message = ex.Message;
                Logger.WriteErrorLog("DeliveryAddrService", "DeleteById", ex);
            }
            return(result);
        }
Exemplo n.º 7
0
        public void ValueEquals()
        {
            var o1 = new Operate(1);
            var o2 = new Operate(1);

            Assert.That(o1, Is.EqualTo(o2));//值相等
        }
Exemplo n.º 8
0
        public JsonResult Measure(string stationCode)
        {
            Guser user = HttpContext.Session.Get <Guser>("SESSION-ACCOUNT-KEY");

            if (!(user.Roles.Equals("Administrator") || user.Roles.Equals("Operator")))
            {
                return(Json(new { code = -1, msg = "只有管理员或者操作人员可以遥控设备" }));
            }

            Operate operate = _context.Operate.Where(q => q.ClientCode.Equals(stationCode) &&
                                                     q.FunctionCode.Equals("B0") && (q.State == OperateState.Before || q.State == OperateState.Sended)).FirstOrDefault();

            if (operate != null)
            {
                return(Json(new { code = 1, msg = "命令已下发" }));
            }

            operate = new Operate()
            {
                ClientCode   = stationCode,
                FunctionCode = "B0"
            };

            _context.Operate.Add(operate);

            _context.SaveChanges();

            return(Json(new { code = 1, msg = "命令已下发" }));
        }
Exemplo n.º 9
0
        public GridPage <List <SkuSaleQueryReport> > SkuSaleQuery(DatetimePointPageReq pageReq)
        {
            var res = new GridPage <List <SkuSaleQueryReport> > {
                code = ResCode.Success
            };
            StringBuilder     sbCommon = new StringBuilder();
            List <FilterNode> list     = new List <FilterNode>();

            foreach (var item in pageReq.query)
            {
                if (item.value != null)
                {
                    switch (item.key.ToLower())
                    {
                    case "storename":
                        sbCommon.Append($" {item.andorop} PlatformUserName in ({item.value}) ");
                        break;

                    case "sku":
                        sbCommon.Append($" {item.andorop} PcrProductSku {Operate.GetSqlOperate(item.binaryop)} '{item.value}' ");
                        break;

                    default:
                        sbCommon.Append($" {item.andorop} {item.key} {Operate.GetSqlOperate(item.binaryop)} '{item.value}' ");
                        break;
                    }
                }
            }
            var whereSql = new SqlParameter("@whereSql", sbCommon.ToString());

            pageReq.query = list;
            res           = DataBaseHelper <SkuSaleQueryReport> .GetFromProcedure(_uowProvider, res, pageReq, false, "EXECUTE SkuSaleQuery_sp @whereSql", whereSql);

            return(res);
        }
Exemplo n.º 10
0
        private void button15_Click(object sender, EventArgs e)
        {
            if (mode != Operate.none)
            {
                //等于===== /
                if (mode == Operate.plus)
                {
                    result = number2 + number;
                }
                if (mode == Operate.minus)
                {
                    result = number2 - number;
                }
                if (mode == Operate.mutiplication)
                {
                    result = number2 * number;
                }
                if (mode == Operate.division)
                {
                    result = number2 / number;
                }

                cleanall();
                number        = result;
                mode          = Operate.none;
                viewbase.Text = Convert.ToString(result);
            }
        }
Exemplo n.º 11
0
        public static Operate ToOperate(this string src)
        {
            Operate type;

            Operate.TryParse(src.ToBigCamelCase(), out type);
            return(type);
        }
Exemplo n.º 12
0
        public void ExportOrderCostTotal(DatetimePointPageReq pageReq)
        {
            var res = new GridPage <List <OrderCostTotalReport> > {
                code = ResCode.Success
            };
            StringBuilder     sbCommon = new StringBuilder();
            List <FilterNode> list     = new List <FilterNode>();

            foreach (var item in pageReq.query)
            {
                if (item.value != null)
                {
                    switch (item.key.ToLower())
                    {
                    case "storename":
                        sbCommon.Append($" {item.andorop} PlatformUserName {Operate.GetSqlOperate(item.binaryop)} '{item.value}' ");
                        break;

                    default:
                        sbCommon.Append($" {item.andorop} {item.key} {Operate.GetSqlOperate(item.binaryop)} '{item.value}' ");
                        break;
                    }
                }
            }
            var whereSql = new SqlParameter("@whereSql", sbCommon.ToString());

            pageReq.query = list;
            res           = DataBaseHelper <OrderCostTotalReport> .GetFromProcedure(_uowProvider, res, pageReq, true, "EXECUTE OrderCostStore_sp @whereSql", whereSql);

            Response.Headers.Add("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode("OrderCostTotalReport.xlsx"));
            Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8";
            Response.Body.Write(ExcelHelper <OrderCostTotalReport> .NpoiListToExcel(res.data));
            Response.Body.Flush();
            Response.Body.Close();
        }
Exemplo n.º 13
0
 protected void lnk_Delete_Click(object sender, System.EventArgs e)
 {
     if (!base.IsAuthorizedOp(ActionType.Delete.ToString()))
     {
         base.ShowAjaxMsg(this.UpdatePanel1, "Không có thẩm quyền");
     }
     else
     {
         int         @int     = WebUtils.GetInt((sender as LinkButton).CommandArgument);
         OperateInfo dataById = Operate.GetDataById(@int);
         if (dataById == null)
         {
             base.ShowAjaxMsg(this.UpdatePanel1, "Không tìm thấy dữ liệu, dữ liệu không tồn tại hoặc đã bị xóa ");
         }
         else if (Operate.Delete(@int))
         {
             Purview.Delete(this.module.AutoID, dataById.OperateCode);
             CacheUtils.Del("JsonLeeCMS_CacheForGetAccountMenuDT");
             PageBase.log.AddEvent(base.LoginAccount.AccountName, string.Concat(new string[]
             {
                 "删除模块[",
                 (this.module == null) ? string.Empty : this.module.ModuleName,
                 "]的操作种类[",
                 dataById.OperateName,
                 "] thành công"
             }));
             this.BindData();
             base.ShowAjaxMsg(this.UpdatePanel1, "Thao tác thành công");
         }
         else
         {
             base.ShowAjaxMsg(this.UpdatePanel1, "Thao tác thất bại");
         }
     }
 }
Exemplo n.º 14
0
        public MainWindow()
        {
            InitializeComponent();
            Loaded += MainWindow_Loaded;

            _Tool = new Operate();
            _Tool.Init();

            try
            {
                new Thread(() =>
                {
                    var time       = new System.Timers.Timer(60000);
                    time.AutoReset = true;
                    time.Elapsed  += (sender, ee) => {
                        SetAllValids();
                    };
                    time.Start();
                }).Start();
                new Thread(() => {
                    Log.ImagesClear(DateTime.Now.AddHours(-2.0));
                }).Start();
            }
            catch (Exception e)
            {
                Log.WriteLine("Exception" + e.Message);
            }
        }
Exemplo n.º 15
0
        public static void Save(Data.Operation oper, string dest)
        {
            var dat = new Operate();

            dat.Index       = oper.Index;
            dat.RewindArray = oper.GetRewindStack();
            List <Operate.DestData> dd = new List <Operate.DestData>();

            foreach (var d in oper.Data.GetDestinationsKeys())
            {
                dd.Add(new Operate.DestData()
                {
                    LinkKey = d, Dest = oper.Data.GetDestination(d).DestPath
                });
            }
            dat.DestArray = dd.ToArray();
            List <Operate.Element> el = new List <Operate.Element>();

            foreach (var e in oper.Data.GetElementsArray())
            {
                var ds = from ar in e.Destinations
                         select ar.Destination;
                el.Add(new Operate.Element()
                {
                    Dest = ds.ToArray <string>(), Source = e.ImageSourcePath, DistributionMode = e.DistributionMode
                });
            }
            dat.ElementArray = el.ToArray();
            var bf = new BinaryFormatter();

            using (FileStream fs = new FileStream(dest, FileMode.Create, FileAccess.ReadWrite))
            {
                bf.Serialize(fs, dat);
            }
        }
Exemplo n.º 16
0
        public static Data.Operation Load(string source)
        {
            Operate op = null;
            var     bf = new BinaryFormatter();

            using (FileStream fs = new FileStream(source, FileMode.Open, FileAccess.Read))
            {
                op = bf.Deserialize(fs) as Operate;
            }
            var newop = new Data.Operation(op.Index, op.RewindArray);

            foreach (var dest in op.DestArray)
            {
                newop.Data.AddDestination(dest.LinkKey, new Bright.Data.Destination(dest.LinkKey, dest.Dest));
            }
            foreach (var elem in op.ElementArray)
            {
                var ne = new Bright.Data.GroupingElement(elem.Source)
                {
                    DistributionMode = elem.DistributionMode
                };
                foreach (var dpath in elem.Dest)
                {
                    ne.Destinations.Add(new Bright.Data.GroupingElement.DestData(dpath));
                }
                newop.Data.AddElement(ne);
            }
            return(newop);
        }
Exemplo n.º 17
0
        public void UpdateTermSource(TermSourceModel item, Operate operate)
        {
            var entity = new SD_TermSource
            {
                CCCode     = item.CCCode,
                Source     = item.Source,
                CreateDate = item.CreateDate
            };

            switch (operate)
            {
            case Operate.Create:
                _termSourceRepository.Add(entity);
                break;

            case Operate.Delete:
                var termSourceItem = _termSourceRepository.GetQuery()
                                     .Where(t => t.CCCode == entity.CCCode && t.Source == entity.Source).FirstOrDefault();
                if (termSourceItem != null)
                {
                    _termSourceRepository.Delete(termSourceItem);
                }
                break;

            default:
                _termSourceRepository.Update(entity);
                break;
            }
        }
Exemplo n.º 18
0
        /// <summary>
        /// 執行 HMACSHA256 加密
        /// </summary>
        /// <param name="args"></param>
        private static void ExecuteHMACSHA256(Operate operate, string[] args)
        {
            var result = new Dictionary <string, object>();

            // 訊息內容
            var message = args[2];

            switch (operate)
            {
            case Operate.Hash:
                result.Add(nameof(Operate.Hash), HashTool.HMACSHA256(message));
                break;

            case Operate.Verify:
                var hash = args[3];
                result.Add(nameof(Operate.Verify), HashTool.VerifyHMACSHA256(message, hash));
                break;

            default:
                break;
            }

            // 顯示結果
            DisplayResult(result);
        }
Exemplo n.º 19
0
        public void SetAdmin(int id, Boolean state)
        {
            FinancialERPDAL db   = new FinancialERPDAL();
            string          s    = System.Web.HttpContext.Current.Session["UserID"].ToString();
            User            user = (from m in db.Users
                                    where m.UserID == id
                                    select m).Single <User>();

            user.UAuthority = state;
            Operate o = new Operate();

            o.AdminID     = int.Parse(s);
            o.UserID      = id;
            o.OperateDate = DateTime.Now;
            if (state)
            {
                o.OperateState = "授权";
            }
            else
            {
                o.OperateState = "撤销";
            }
            db.Operates.Add(o);
            db.SaveChanges();
        }
Exemplo n.º 20
0
        public GridPage <List <ECHeadTripLine> > GetECHeadTripLinesPage(DatetimePointPageReq pageReq)
        {
            var res = new GridPage <List <ECHeadTripLine> >()
            {
                code = ResCode.Success
            };
            StringBuilder     sbCommon   = new StringBuilder();
            StringBuilder     sbLoandate = new StringBuilder();
            List <FilterNode> list       = new List <FilterNode>();

            foreach (var item in pageReq.query)
            {
                if (item.value != null)
                {
                    switch (item.key.ToLower())
                    {
                    case "addtime":
                        if (item.binaryop == "gt")
                        {
                            sbCommon.Append($" and t1.AddTime >= '{item.value}'");
                        }
                        if (item.binaryop == "lt")
                        {
                            sbCommon.Append($" and t1.AddTime <= '{item.value}'");
                        }
                        break;

                    case "itemsku":
                        sbCommon.Append($" and t4.PcrProductSku {Operate.GetSqlOperate(item.binaryop)} '{item.value}'");
                        break;

                    case "storename":
                        sbCommon.Append($" and t1.PlatformUserName {Operate.GetSqlOperate(item.binaryop)} '{item.value}'");
                        break;

                    case "towarehouse":
                        sbCommon.Append($" and ToWarehouse {Operate.GetSqlOperate(item.binaryop)} '{item.value}'");
                        break;

                    case "warehouse":
                        sbCommon.Append($" and Warehouse {Operate.GetSqlOperate(item.binaryop)} '{item.value}'");
                        break;

                    case "ordercode":
                        sbCommon.Append($" and t1.Ordercode {Operate.GetSqlOperate(item.binaryop)} '{item.value}'");
                        break;

                    case "companyname":
                        sbCommon.Append($" and company {Operate.GetSqlOperate(item.binaryop)} '{item.value}'");
                        break;
                    }
                }
            }
            var whereSql = new SqlParameter("@whereSql", sbCommon.ToString());

            res = DataBaseHelper <ECHeadTripLine> .GetFromProcedure(_uowProvider, res, pageReq, false, "EXECUTE ShipBatckQuery_sp @whereSql", whereSql);

            return(res);
        }
Exemplo n.º 21
0
        public async Task <Operate> BorrowBook(long bookId, long userId, DateTime planReturnDate)
        {
            var result = new Operate();

            try
            {
                //if this book has been borrowed
                var bookEntity = await bookInfoAgent.GetById(bookId);

                if (bookEntity.Status == (int)Enums.BookStatus.Borrowed)
                {
                    result.Status  = -1;
                    result.Message = "This book has been borrowed";
                    return(result);
                }

                using (var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
                {
                    //update status of book info
                    bookEntity.Status = (int)Enums.BookStatus.Borrowed;
                    await bookInfoAgent.AddOrUpdate(bookEntity);

                    /* book borrow
                     * 1. if current user has been borrowed this book, only change status and book borrow date
                     * 2. if current user is first to borrow this book, create new data
                     */
                    var now = DateTime.Now;
                    var bookBorrowEntity = await bookBorrowAgent.GetbyBookIdAndUserId(bookId, userId);

                    if (bookBorrowEntity != null)
                    {
                        bookBorrowEntity.Status         = (int)Enums.BookStatus.Borrowed;
                        bookBorrowEntity.BorrowDate     = now;
                        bookBorrowEntity.PlanReturnDate = planReturnDate;
                        await bookBorrowAgent.AddOrUpdate(bookBorrowEntity);
                    }
                    else
                    {
                        var bookBorrowModel = new BookBorrow
                        {
                            BookId         = bookId,
                            BorrowUserId   = userId,
                            Status         = (int)Enums.BookStatus.Borrowed,
                            BorrowDate     = now,
                            PlanReturnDate = planReturnDate
                        };
                        await bookBorrowAgent.AddOrUpdate(bookBorrowModel);
                    }
                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                result.Status  = -1;
                result.Message = ex.Message;
                Logger.WriteErrorLog(ex);
            }
            return(result);
        }
Exemplo n.º 22
0
 public void Push(Operate operateType, string table = "")
 {
     if (!table.HasValue())
     {
         table = CurrentTable;
     }
     Push(new DbOperate(_paramDictionary, operateType, _dataBase, table));
 }
Exemplo n.º 23
0
 public MainPage()
 {
     this.InitializeComponent();
     _lastOperate = new Operate();
     Debug.WriteLine(_lastOperate.Type);
     InitHandler();
     Logic.Instance.CommunicationHandler += Instance_CommunicationHandler;;
 }
Exemplo n.º 24
0
 public FrmMain()
 {
     InitializeComponent();
     op = new Operate();
     Public.Operate.OnFilePathError       += Operate_OnFilePathError;
     Public.Operate.OnFileOperate         += Operate_OnFileOperate;
     Public.Operate.OnFileOperateComplete += Operate_OnFileOperateComplete;
 }
Exemplo n.º 25
0
        public int AddTest()
        {
            var result = Operate.Add(1, 2);

            Assert.That(result, Is.GreaterThan(2));
            Assert.That(result, Is.EqualTo(3));
            return(result);
        }
Exemplo n.º 26
0
 private void btnRestore_Click(object sender, EventArgs e)
 {
     if (XtraMessageBoxHelper.ShowYesNoAndTips("确实要还原选中的数据吗?") == System.Windows.Forms.DialogResult.Yes)
     {
         Restore();
         Operate.LoadMethod();
     }
 }
Exemplo n.º 27
0
        /// <summary>
        /// 获取详情
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task <OperateResponse> Detail(int id)
        {
            using (_db)
            {
                Operate operate = await _db.Operate.FindByIdAsync(id);

                return(_mapper.Map <OperateResponse>(operate));
            }
        }
Exemplo n.º 28
0
 Expression parseExpression()
 {
     Expression ExpAST;
     PrimaryExpression P1 = parsePrimary();
     Operate O = parseOperator();
     PrimaryExpression P2 = parsePrimary();
     ExpAST = new Expression(P1, O, P2);
     return ExpAST;
 }
Exemplo n.º 29
0
        private void BindData()
        {
            int    recordCount = 0;
            int    num         = 0;
            string strSort     = "Sort asc,AutoID asc";

            this.Repeater1.DataSource = Operate.GetPagerList(this.GetCondition(), strSort, this.SinGooPager1.PageIndex, this.SinGooPager1.PageSize, ref recordCount, ref num);
            this.Repeater1.DataBind();
            this.SinGooPager1.RecordCount = recordCount;
        }
Exemplo n.º 30
0
 public BinaryOperate(Element left, Element right, Operate op = Operate.Multiply)
 {
     if (left == null || right == null)
     {
         throw new ArgumentNullException("element is null!");
     }
     m_left  = left;
     m_right = right;
     m_op    = op;
 }
Exemplo n.º 31
0
        public object visitOperator(Operate o, object arg)
        {
            Declaration binding = idTable.retrieve(o.Spelling);

            if (binding != null)
            {
                o.OperatorDeclaration = binding;
            }
            return(binding);
        }
Exemplo n.º 32
0
        public void Load(int pathIndex, MapPathSetting data, Operate operateSet, Operate operateRemove)
        {
            this.pathIndex = pathIndex;
            this.operateSet = operateSet;
            this.operateRemove = operateRemove;

            ColorField.color = new Color(data.ColorR, data.ColorG, data.ColorB);

            for (int i = WaypointGroup.transform.childCount - 1; i >= 0; --i)
                GameObject.DestroyImmediate(WaypointGroup.transform.GetChild(i).gameObject);

            int lineHeight = 24;
            for (int i = 0; i < data.Waypoints.Length; ++i)
            {
                MapWaypointSetting waypointSetting = data.Waypoints[i];
                GameObject WaypointEntry = GameObject.Instantiate(WaypointEntryPrefab);
                WaypointEntry.transform.SetParent(WaypointGroup.transform, false);
                WaypointEntry.transform.localPosition = new Vector3(0, -i * lineHeight);
                UIBase.FindUIObject<Text>(WaypointEntry, "Text").text = string.Format("{0}:({1}, {2})", i, waypointSetting.X, waypointSetting.Y);
                UIBase.FindUIObject<Button>(WaypointEntry, "ResetButton").onClick.AddListener(OnResetPoint(i));
                UIBase.FindUIObject<Button>(WaypointEntry, "RemoveButton").onClick.AddListener(OnRemovePoint(i));
            }
            gameObject.GetComponent<LayoutElement>().minHeight = lineHeight * data.Waypoints.Length + 12;
        }
Exemplo n.º 33
0
        public ResultModel CreateProvisional(UserModel user, Operate.Model.Invoice invoice, BusinessInvoice invoiceBusiness, List<BusinessInvoiceDetail> details)
        {
            ResultModel result = new ResultModel();

            StockLogDAL stockLogDAL = new StockLogDAL();

            foreach (BusinessInvoiceDetail detail in details)
            {
                detail.UnitPrice = invoiceBusiness.UnitPrice;
                result = stockLogDAL.Get(user, detail.StockLogId);
                if (result.ResultStatus != 0)
                    return result;

                StockLog stockLog = result.ReturnValue as StockLog;
                if (stockLog == null || stockLog.StockLogId <= 0)
                {
                    result.ResultStatus = -1;
                    result.Message = "当前合约不存在该笔库存";
                    return result;
                }
                detail.IntegerAmount = stockLog.GrossAmount;
            }

            invoiceBusiness.IntegerAmount = details.Sum(temp => temp.IntegerAmount);

            //验证是否已开直接终票
            result = this.businessinvoiceDAL.LoadBySubId(user, invoiceBusiness.SubContractId, InvoiceTypeEnum.DirectFinalInvoice);
            if (result.ResultStatus != 0)
                return result;

            List<BusinessInvoice> dirInvoices = result.ReturnValue as List<BusinessInvoice>;
            if (dirInvoices == null)
            {
                result.ResultStatus = -1;
                result.Message = "验证是否拥有直接终票失败";
                return result;
            }
            if (dirInvoices.Count > 0)
            {
                result.ResultStatus = -1;
                result.Message = "当前合约已拥有直接终票,临票失败";
                return result;
            }

            result = this.CreateBusinessInvoice(user, invoice, invoiceBusiness, details, InvoiceTypeEnum.ProvisionalInvoice);

            return result;
        }
Exemplo n.º 34
0
        public ResultModel CreateReplaceFinal(UserModel user, Operate.Model.Invoice invoice, BusinessInvoice invoiceBusiness, List<BusinessInvoiceDetail> details)
        {
            ResultModel result = new ResultModel();

            StockLogDAL stockLogDAL = new StockLogDAL();

            foreach (BusinessInvoiceDetail detail in details)
            {
                result = stockLogDAL.Get(user, detail.StockLogId);
                if (result.ResultStatus != 0)
                    return result;

                StockLog stockLog = result.ReturnValue as StockLog;
                if (stockLog == null || stockLog.StockLogId <= 0)
                {
                    result.ResultStatus = -1;
                    result.Message = "当前合约不存在该笔库存";
                    return result;
                }
                detail.IntegerAmount = stockLog.GrossAmount;
            }

            decimal sumNetAmount = details.Sum(temp => temp.NetAmount);
            if (sumNetAmount != invoiceBusiness.NetAmount)
            {
                result.ResultStatus = -1;
                result.Message = "明细净重之和与总净重不相等";
                return result;
            }

            decimal sumBala = details.Sum(temp => temp.Bala);
            if (sumBala != invoice.InvoiceBala)
            {
                result.ResultStatus = -1;
                result.Message = "明细金额之和与总金额不相等";
                return result;
            }

            decimal sumUnitBala = Math.Round(details.Sum(temp => temp.UnitPrice * temp.NetAmount),2,MidpointRounding.AwayFromZero);
            decimal avgPrice = Math.Round(sumUnitBala / sumNetAmount, 4, MidpointRounding.AwayFromZero);

            invoiceBusiness.UnitPrice = avgPrice;
            invoiceBusiness.IntegerAmount = details.Sum(temp => temp.IntegerAmount);

            result = this.CreateBusinessInvoice(user, invoice, invoiceBusiness, details, InvoiceTypeEnum.ReplaceFinalInvoice);

            return result;
        }
Exemplo n.º 35
0
 public ResultModel CreateSuppleFinal(UserModel user, Operate.Model.Invoice invoice, BusinessInvoice invoiceBusiness, List<BusinessInvoiceDetail> details)
 {
     return this.CreateBusinessInvoice(user, invoice, invoiceBusiness, details, InvoiceTypeEnum.SuppleFinalInvoice);
 }
Exemplo n.º 36
0
			public static OperateData Create(Operate opt, params object[] args)
			{
				return new OperateData(opt, args);
			}
Exemplo n.º 37
0
 public ResultModel UpdateSuppleFinal(UserModel user, Operate.Model.Invoice invoice, BusinessInvoice replaceBusiness, List<BusinessInvoiceDetail> details)
 {
     return this.UpdateBusinessInvoice(user, invoice, replaceBusiness, details);
 }
Exemplo n.º 38
0
        public ResultModel Update(UserModel user, Operate.Model.Invoice invoice, FinanceInvoice fundsInvoice,string bids)
        {
            ResultModel result = new ResultModel();

            try
            {
                FinanceInvoiceDAL fundsInvoiceDAL = new FinanceInvoiceDAL();
                InvoiceDAL invoiceDAL = new InvoiceDAL();

                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {

                    //获取财务发票
                    result = fundsInvoiceDAL.Get(user, fundsInvoice.FinanceInvoiceId);
                    if (result.ResultStatus != 0)
                        return result;

                    FinanceInvoice resultFundsInvoice = result.ReturnValue as FinanceInvoice;
                    if (resultFundsInvoice == null || resultFundsInvoice.FinanceInvoiceId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "财务发票获取失败";
                        return result;
                    }

                    //更新财务发票
                    resultFundsInvoice.AssetId = fundsInvoice.AssetId;
                    resultFundsInvoice.IntegerAmount = fundsInvoice.IntegerAmount;
                    resultFundsInvoice.NetAmount = fundsInvoice.NetAmount;
                    resultFundsInvoice.MUId = fundsInvoice.MUId;
                    resultFundsInvoice.VATRatio = fundsInvoice.VATRatio;
                    resultFundsInvoice.VATBala = fundsInvoice.VATBala;

                    result = fundsInvoiceDAL.Update(user, resultFundsInvoice);
                    if (result.ResultStatus != 0)
                        return result;

                    //获取发票
                    result = invoiceDAL.Get(user, resultFundsInvoice.InvoiceId);
                    if (result.ResultStatus != 0)
                        return result;
                    Operate.Model.Invoice resultInvoice = result.ReturnValue as Operate.Model.Invoice;
                    if (resultInvoice == null || resultInvoice.InvoiceId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "发票信息获取失败";
                        return result;
                    }

                    resultInvoice.InvoiceDate = invoice.InvoiceDate;
                    resultInvoice.InvoiceName = invoice.InvoiceName;
                    resultInvoice.InvoiceBala = invoice.InvoiceBala;
                    resultInvoice.CurrencyId = invoice.CurrencyId;
                    resultInvoice.OutCorpId = invoice.OutCorpId;

                    Corporation outCorp = UserProvider.Corporations.FirstOrDefault(temp => temp.CorpId == invoice.OutCorpId);
                    if (outCorp == null || outCorp.CorpId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "开票公司信息错误";
                        return result;
                    }
                    resultInvoice.OutCorpName = outCorp.CorpName;

                    resultInvoice.InCorpId = invoice.InCorpId;
                    Corporation inCorp = UserProvider.Corporations.FirstOrDefault(temp => temp.CorpId == invoice.InCorpId);
                    if (inCorp == null || inCorp.CorpId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "收票公司信息错误";
                        return result;
                    }
                    resultInvoice.InCorpName = inCorp.CorpName;
                    resultInvoice.Memo = invoice.Memo;

                    result = invoiceDAL.Update(user, resultInvoice);
                    if (result.ResultStatus != 0)
                        return result;

                    if (!string.IsNullOrEmpty(bids))
                    {
                        FinBusInvAllotDAL finBusInvAllotDAL = new FinBusInvAllotDAL();
                        FinBusInvAllotDetailDAL finBusInvAllotDetailDAL = new FinBusInvAllotDetailDAL();
                        result = finBusInvAllotDetailDAL.GetAllotIdByFid(user, fundsInvoice.FinanceInvoiceId);
                        if (result.ResultStatus != 0)
                            return result;

                        int allotId = (int)result.ReturnValue;

                        result = finBusInvAllotDAL.Get(user, allotId);
                        if (result.ResultStatus != 0)
                            return result;

                        FinBusInvAllot finBusInvAllot = result.ReturnValue as FinBusInvAllot;
                        finBusInvAllot.AllotBala = invoice.InvoiceBala;

                        result = finBusInvAllotDAL.Update(user, finBusInvAllot);
                        if (result.ResultStatus != 0)
                            return result;

                        result = finBusInvAllotDetailDAL.InvalidAll(user, allotId);
                        if (result.ResultStatus != 0)
                            return result;

                        foreach (string businessInvoiceId in bids.Split(','))
                        {
                            result = invoiceDAL.GetByBussinessInvoiceId(user, Convert.ToInt32(businessInvoiceId));
                            if (result.ResultStatus != 0)
                                return result;

                            Operate.Model.Invoice busInvoice = result.ReturnValue as Operate.Model.Invoice;

                            result = finBusInvAllotDetailDAL.Insert(user, new FinBusInvAllotDetail()
                            {
                                AllotId = allotId,
                                BusinessInvoiceId = Convert.ToInt32(businessInvoiceId),
                                FinanceInvoiceId = fundsInvoice.FinanceInvoiceId,
                                AllotBala = busInvoice.InvoiceBala,
                                DetailStatus = StatusEnum.已生效
                            });
                            if (result.ResultStatus != 0)
                                return result;
                        }

                    }

                    if (result.ResultStatus == 0)
                        result.ReturnValue = invoice.InvoiceId;

                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                result.ResultStatus = -1;
                result.Message = ex.Message;
            }

            return result;
        }
Exemplo n.º 39
0
			public OperateData(TCPSessionInfo s, Operate o, object[] a = null)
			{
				session = s;
				opt = o;
				args = a;
			}
Exemplo n.º 40
0
        public ResultModel CreateByInvApply(UserModel user, Operate.Model.Invoice invoice, FinanceInvoice fundsInvoice, string bids, int invoiceApplyId)
        {
            ResultModel result = new ResultModel();

            try
            {
                FinanceInvoiceDAL fundsInvoiceDAL = new FinanceInvoiceDAL();
                InvoiceDAL invoiceDAL = new InvoiceDAL();

                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    //新增发票主表
                    int invoiceId = 0;

                    invoice.InvoiceType = (int)InvoiceTypeEnum.财务发票;

                    invoice.InvoiceStatus = StatusEnum.已录入;
                    Corporation outCorp = UserProvider.Corporations.FirstOrDefault(temp => temp.CorpId == invoice.OutCorpId);
                    if (outCorp == null || outCorp.CorpId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "开票公司信息错误";
                        return result;
                    }
                    invoice.OutCorpName = outCorp.CorpName;
                    //invoice.OutBlocId = outCorp.b

                    Corporation inCorp = UserProvider.Corporations.FirstOrDefault(temp => temp.CorpId == invoice.InCorpId);
                    if (inCorp == null || inCorp.CorpId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "收票公司信息错误";
                        return result;
                    }
                    invoice.InCorpName = inCorp.CorpName;

                    result = invoiceDAL.Insert(user, invoice);
                    if (result.ResultStatus != 0)
                        return result;

                    if (result.ReturnValue == null || !int.TryParse(result.ReturnValue.ToString(), out invoiceId))
                    {
                        result.ResultStatus = -1;
                        result.Message = "发票添加失败";
                        return result;
                    }

                    //新增财务发票表
                    fundsInvoice.InvoiceId = invoiceId;
                    fundsInvoice.VATRatio = fundsInvoice.VATRatio;
                    result = fundsInvoiceDAL.Insert(user, fundsInvoice);
                    if (result.ResultStatus != 0)
                        return result;

                    int financeInvoiceId = (int)result.ReturnValue;

                    //财务发票业务发票分配
                    if (!string.IsNullOrEmpty(bids))
                    {
                        FinBusInvAllotDAL finBusInvAllotDAL = new FinBusInvAllotDAL();
                        result = finBusInvAllotDAL.Insert(user, new FinBusInvAllot()
                        {
                            AllotBala = invoice.InvoiceBala,
                            CurrencyId = invoice.CurrencyId,
                            Alloter = user.EmpId,
                            AllotDate = DateTime.Now,
                            AllotStatus = StatusEnum.已生效
                        });

                        if (result.ResultStatus != 0)
                            return result;

                        int allotId = (int)result.ReturnValue;

                        FinBusInvAllotDetailDAL finBusInvAllotDetailDAL = new FinBusInvAllotDetailDAL();
                        foreach (string businessInvoiceId in bids.Split(','))
                        {
                            result = invoiceDAL.GetByBussinessInvoiceId(user, Convert.ToInt32(businessInvoiceId));
                            if (result.ResultStatus != 0)
                                return result;

                            Operate.Model.Invoice busInvoice = result.ReturnValue as Operate.Model.Invoice;

                            result = finBusInvAllotDetailDAL.Insert(user, new FinBusInvAllotDetail()
                            {
                                AllotId = allotId,
                                BusinessInvoiceId = Convert.ToInt32(businessInvoiceId),
                                FinanceInvoiceId = financeInvoiceId,
                                AllotBala = busInvoice.InvoiceBala,
                                DetailStatus = StatusEnum.已生效
                            });
                            if (result.ResultStatus != 0)
                                return result;
                        }
                    }

                    //添加开票申请与财务票关联
                    InvoiceApplyFinanceDAL invoiceApplyFinanceDAL = new InvoiceApplyFinanceDAL();
                    result = invoiceApplyFinanceDAL.Insert(user, new InvoiceApplyFinance()
                    {
                        InvoiceId = invoiceId,
                        FinanceInvoiceId = financeInvoiceId,
                        InvoiceApplyId = invoiceApplyId
                    });
                    if (result.ResultStatus != 0)
                        return result;

                    invoice.InvoiceId = invoiceId;
                    if (result.ResultStatus == 0) result.ReturnValue = invoice;

                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                result.ResultStatus = -1;
                result.Message = ex.Message;
            }

            return result;
        }
Exemplo n.º 41
0
        public ResultModel Update(UserModel user, Operate.Model.Invoice invoice, FinanceInvoice fundsInvoice)
        {
            ResultModel result = new ResultModel();

            try
            {
                FinanceInvoiceDAL fundsInvoiceDAL = new FinanceInvoiceDAL();
                InvoiceDAL invoiceDAL = new InvoiceDAL();

                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {

                    //获取财务发票
                    result = fundsInvoiceDAL.Get(user, fundsInvoice.FinanceInvoiceId);
                    if (result.ResultStatus != 0)
                        return result;

                    FinanceInvoice resultFundsInvoice = result.ReturnValue as FinanceInvoice;
                    if (resultFundsInvoice == null || resultFundsInvoice.FinanceInvoiceId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "财务发票获取失败";
                        return result;
                    }

                    //更新财务发票
                    resultFundsInvoice.AssetId = fundsInvoice.AssetId;
                    resultFundsInvoice.IntegerAmount = fundsInvoice.IntegerAmount;
                    resultFundsInvoice.NetAmount = fundsInvoice.NetAmount;
                    resultFundsInvoice.MUId = fundsInvoice.MUId;
                    resultFundsInvoice.VATRatio = fundsInvoice.VATRatio;
                    resultFundsInvoice.VATBala = fundsInvoice.VATBala;

                    result = fundsInvoiceDAL.Update(user, resultFundsInvoice);
                    if (result.ResultStatus != 0)
                        return result;

                    //获取发票
                    result = invoiceDAL.Get(user, resultFundsInvoice.InvoiceId);
                    if (result.ResultStatus != 0)
                        return result;
                    Operate.Model.Invoice resultInvoice = result.ReturnValue as Operate.Model.Invoice;
                    if (resultInvoice == null || resultInvoice.InvoiceId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "发票信息获取失败";
                        return result;
                    }

                    resultInvoice.InvoiceDate = invoice.InvoiceDate;
                    resultInvoice.InvoiceName = invoice.InvoiceName;
                    resultInvoice.InvoiceBala = invoice.InvoiceBala;
                    resultInvoice.CurrencyId = invoice.CurrencyId;
                    resultInvoice.OutCorpId = invoice.OutCorpId;

                    Corporation outCorp = UserProvider.Corporations.FirstOrDefault(temp => temp.CorpId == invoice.OutCorpId);
                    if (outCorp == null || outCorp.CorpId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "开票公司信息错误";
                        return result;
                    }
                    resultInvoice.OutCorpName = outCorp.CorpName;

                    resultInvoice.InCorpId = invoice.InCorpId;
                    Corporation inCorp = UserProvider.Corporations.FirstOrDefault(temp => temp.CorpId == invoice.InCorpId);
                    if (inCorp == null || inCorp.CorpId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "收票公司信息错误";
                        return result;
                    }
                    resultInvoice.InCorpName = inCorp.CorpName;
                    resultInvoice.Memo = invoice.Memo;

                    result = invoiceDAL.Update(user, resultInvoice);
                    if (result.ResultStatus != 0)
                        return result;

                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                result.ResultStatus = -1;
                result.Message = ex.Message;
            }

            return result;
        }
Exemplo n.º 42
0
        public ResultModel Create(UserModel user, Operate.Model.Invoice invoice, FinanceInvoice fundsInvoice)
        {
            ResultModel result = new ResultModel();

            try
            {
                FinanceInvoiceDAL fundsInvoiceDAL = new FinanceInvoiceDAL();
                InvoiceDAL invoiceDAL = new InvoiceDAL();

                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    //新增发票主表
                    int invoiceId = 0;

                    invoice.InvoiceType = (int)InvoiceTypeEnum.财务发票;

                    invoice.InvoiceStatus = StatusEnum.已录入;
                    Corporation outCorp = UserProvider.Corporations.FirstOrDefault(temp => temp.CorpId == invoice.OutCorpId);
                    if (outCorp == null || outCorp.CorpId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "开票公司信息错误";
                        return result;
                    }
                    invoice.OutCorpName = outCorp.CorpName;
                    //invoice.OutBlocId = outCorp.b

                    Corporation inCorp = UserProvider.Corporations.FirstOrDefault(temp => temp.CorpId == invoice.InCorpId);
                    if (inCorp == null || inCorp.CorpId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "收票公司信息错误";
                        return result;
                    }
                    invoice.InCorpName = inCorp.CorpName;

                    result = invoiceDAL.Insert(user, invoice);
                    if (result.ResultStatus != 0)
                        return result;

                    if (result.ReturnValue == null || !int.TryParse(result.ReturnValue.ToString(), out invoiceId))
                    {
                        result.ResultStatus = -1;
                        result.Message = "发票添加失败";
                        return result;
                    }

                    //新增财务发票表
                    fundsInvoice.InvoiceId = invoiceId;
                    fundsInvoice.VATRatio = fundsInvoice.VATRatio;
                    result = fundsInvoiceDAL.Insert(user, fundsInvoice);
                    if (result.ResultStatus != 0)
                        return result;

                    if (result.ResultStatus == 0) result.ReturnValue = invoiceId;

                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                result.ResultStatus = -1;
                result.Message = ex.Message;
            }

            return result;
        }
Exemplo n.º 43
0
 public string GetConfirmText(Operate operate)
 {
     string confirmText = "";
     switch (operate)
     {
         case Operate.Add:
             confirmText = "添加";
             break;
         case Operate.Edit:
             confirmText = "修改";
             break;
         case Operate.Del:
             confirmText = "删除";
             break;
         default:
             break;
     }
     return confirmText;
 }
Exemplo n.º 44
0
 public void OperateConfirm(bool result, string callback, Operate operate)
 {
     string confirmText = GetConfirmText(operate);
     if (result)
         jAlert(string.Format("{0}成功!", confirmText), callback);
     else
         jAlert(string.Format("{0}失败!", confirmText));
 }
Exemplo n.º 45
0
        public ResultModel CreateDirect(UserModel user, Operate.Model.Invoice invoice, BusinessInvoice invoiceBusiness, List<BusinessInvoiceDetail> details)
        {
            ResultModel result = new ResultModel();

            ContractSubDAL subDAL = new ContractSubDAL();
            result = subDAL.Get(user, invoiceBusiness.SubContractId);
            if(result.ResultStatus!=0)
                return result;

            ContractSub sub = result.ReturnValue as ContractSub;
            if (sub == null || sub.SubId <= 0)
            {
                result.ResultStatus = -1;
                result.Message = "子合约不存在";
                return result;
            }

            StockLogDAL stockLogDAL = new StockLogDAL();
            //明细表数据:毛重、金额计算
            foreach (BusinessInvoiceDetail detail in details)
            {
                detail.Bala = Math.Round(detail.NetAmount * detail.UnitPrice, 2, MidpointRounding.AwayFromZero);

                if (sub.TradeBorder == (int)TradeBorderEnum.内贸)
                {
                    //内贸毛重==净重
                    detail.IntegerAmount = detail.NetAmount;
                }
                else
                {
                    //整笔开票情况下,外贸毛重等于库存流水毛重;分笔开票情况下,等于净重。
                    result = stockLogDAL.Get(user, detail.StockLogId);
                    if (result.ResultStatus != 0)
                        return result;

                    StockLog stockLog = result.ReturnValue as StockLog;
                    if (stockLog == null || stockLog.StockLogId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "当前合约不存在该笔库存";
                        return result;
                    }

                    if (stockLog.NetAmount == detail.NetAmount)
                    {
                        detail.IntegerAmount = stockLog.GrossAmount;
                    }
                    else
                    {
                        detail.IntegerAmount = detail.NetAmount;
                    }
                }
            }

            //主表数据:毛重、净重、均价、总额计算
            decimal sumGrossAmount = details.Sum(temp => temp.IntegerAmount);
            invoiceBusiness.IntegerAmount = sumGrossAmount;

            decimal sumNetAmount = details.Sum(temp => temp.NetAmount);
            if (sumNetAmount != invoiceBusiness.NetAmount)
            {
                result.ResultStatus = -1;
                result.Message = "明细净重之和与总净重不相等";
                return result;
            }

            decimal sumBala = details.Sum(temp => temp.Bala);
            if (Math.Abs(sumBala - invoice.InvoiceBala) >= 1)
            {
                result.ResultStatus = -1;
                result.Message = "明细金额之和与总金额不相等";
                return result;
            }

            decimal avgPrice = Math.Round(sumBala / sumNetAmount, 4, MidpointRounding.AwayFromZero);
            if (avgPrice != invoiceBusiness.UnitPrice)
            {
                result.ResultStatus = -1;
                result.Message = "计算均价错误";
                return result;
            }

            //验证是否已开临票
            //result = this.businessinvoiceDAL.LoadBySubId(user, invoiceBusiness.SubContractId, InvoiceTypeEnum.ProvisionalInvoice);
            //if (result.ResultStatus != 0)
            //    return result;

            //List<Model.BusinessInvoice> proInvoices = result.ReturnValue as List<Model.BusinessInvoice>;
            //if (proInvoices == null)
            //{
            //    result.ResultStatus = -1;
            //    result.Message = "验证是否拥有临票失败";
            //    return result;
            //}
            //if (proInvoices.Count > 0)
            //{
            //    result.ResultStatus = -1;
            //    result.Message = "当前合约已拥有临票,直接终票失败";
            //    return result;
            //}

            result = this.CreateBusinessInvoice(user, invoice, invoiceBusiness, details, InvoiceTypeEnum.DirectFinalInvoice);

            return result;
        }
Exemplo n.º 46
0
			public static OperateData Create(TCPSessionInfo s, Operate opt, params object[] args)
			{
				return new OperateData(s, opt, args);
			}
Exemplo n.º 47
0
        public ResultModel CreateBusinessInvoice(UserModel user, Operate.Model.Invoice invoice, BusinessInvoice invoiceBusiness, List<BusinessInvoiceDetail> details, InvoiceTypeEnum invoiceType)
        {
            ResultModel result = new ResultModel();

            try
            {
                BusinessInvoiceDAL businessInvoiceDAL = new BusinessInvoiceDAL();
                InvoiceDAL invoiceDAL = new InvoiceDAL();
                BusinessInvoiceDetailDAL detailDAL = new BusinessInvoiceDetailDAL();
                ContractSubDAL subDAL = new ContractSubDAL();
                StockReceiptDetailDAL stockReceiptDetailDAL = new StockReceiptDetailDAL();
                SubDetailDAL subDetailDAL = new SubDetailDAL();

                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    //验证子合约
                    result = subDAL.Get(user, invoiceBusiness.SubContractId);
                    if (result.ResultStatus != 0)
                        return result;

                    ContractSub sub = result.ReturnValue as ContractSub;
                    if (sub == null || sub.SubId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "子合约不存在";
                        return result;
                    }

                    if (sub.SubStatus != StatusEnum.已生效)
                    {
                        result.ResultStatus = -1;
                        result.Message = "子合约非已生效状态,不能新增临票";
                        return result;
                    }

                    //获取子合约明细
                    result = subDetailDAL.GetDetailBySubId(user, sub.SubId);
                    if (result.ResultStatus != 0)
                        return result;

                    SubDetail subDetail = result.ReturnValue as SubDetail;
                    if (subDetail == null || subDetail.SubDetailId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "子合约明细获取失败";
                        return result;
                    }

                    //获取子合约下所有
                    result = this.businessinvoiceDAL.LoadBySubId(user, invoiceBusiness.SubContractId, invoiceType);
                    if (result.ResultStatus != 0)
                        return result;

                    List<BusinessInvoice> bis = result.ReturnValue as List<BusinessInvoice>;
                    decimal sumNetAmount = bis.Sum(temp => temp.NetAmount);
                    decimal maxNetAmount = sub.SignAmount * (1 + subDetail.MoreOrLess);
                    //if (maxNetAmount < sumNetAmount + invoiceBusiness.NetAmount)
                    //{
                    //    result.ResultStatus = -1;
                    //    result.Message = "开票重量超额";
                    //    return result;
                    //}

                    //新增发票主表
                    int invoiceId = 0;
                    invoice.InvoiceType = (int)invoiceType;
                    invoice.InvoiceStatus = StatusEnum.已录入;
                    Corporation outCorp = UserProvider.Corporations.FirstOrDefault(temp => temp.CorpId == invoice.OutCorpId);
                    if (outCorp == null || outCorp.CorpId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "开票公司信息错误";
                        return result;
                    }
                    invoice.OutCorpName = outCorp.CorpName;

                    Corporation inCorp = UserProvider.Corporations.FirstOrDefault(temp => temp.CorpId == invoice.InCorpId);
                    if (inCorp == null || inCorp.CorpId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "收票公司信息错误";
                        return result;
                    }
                    invoice.InCorpName = inCorp.CorpName;

                    result = invoiceDAL.Insert(user, invoice);
                    if (result.ResultStatus != 0)
                        return result;

                    if (result.ReturnValue == null || !int.TryParse(result.ReturnValue.ToString(), out invoiceId))
                    {
                        result.ResultStatus = -1;
                        result.Message = "发票添加失败";
                        return result;
                    }

                    //新增业务发票表
                    int businessInvoiceId = 0;
                    invoiceBusiness.InvoiceId = invoiceId;
                    result = businessInvoiceDAL.Insert(user, invoiceBusiness);
                    if (result.ResultStatus != 0)
                        return result;

                    if (result.ReturnValue == null || !int.TryParse(result.ReturnValue.ToString(), out businessInvoiceId))
                    {
                        result.ResultStatus = -1;
                        result.Message = "新增发票失败";
                        return result;
                    }

                    //新增业务发票明细
                    StockLogDAL stockLogDAL = new StockLogDAL();
                    StockDAL stockDAL = new StockDAL();
                    foreach (BusinessInvoiceDetail detail in details)
                    {
                        if (detail.NetAmount != 0 && detail.StockId > 0)
                        {
                            //验证库存
                            result = stockDAL.Get(user, detail.StockId);
                            if (result.ResultStatus != 0)
                                return result;
                            Stock stock = result.ReturnValue as Stock;
                            if (stock == null || stock.StockId <= 0)
                            {
                                result.ResultStatus = -1;
                                result.Message = "发票库存获取失败";
                                return result;
                            }

                            //验证库存流水
                            result = stockLogDAL.Get(user, detail.StockLogId);
                            if (result.ResultStatus != 0)
                                return result;

                            StockLog stockLog = result.ReturnValue as StockLog;
                            if (stockLog == null || stockLog.StockLogId <= 0)
                            {
                                result.ResultStatus = -1;
                                result.Message = "新增发票流水获取失败";
                                return result;
                            }

                            //基本验证
                            if (stockLog.StockId != stock.StockId)
                            {
                                result.ResultStatus = -1;
                                result.Message = "库存与库存流水不匹配";
                                return result;
                            }

                            //验证流水合约与发票合约是否相同
                            if (stockLog.SubContractId != invoiceBusiness.SubContractId)
                            {
                                result.ResultStatus = -1;
                                result.Message = "合约与库存流水不匹配";
                                return result;
                            }

                            detail.DetailStatus = StatusEnum.已生效;
                            detail.InvoiceId = invoiceId;
                            detail.BusinessInvoiceId = businessInvoiceId;
                            detail.StockId = stockLog.StockId;
                            detail.StockLogId = stockLog.StockLogId;

                            if (invoice.InvoiceType == (int)InvoiceTypeEnum.SuppleFinalInvoice)
                            {
                                //获取当前流水回执信息
                                result = stockReceiptDetailDAL.LoadByStockLogId(user, stockLog.StockLogId);
                                List<StockReceiptDetail> stockReceiptDetails = result.ReturnValue as List<StockReceiptDetail>;
                                if (stockReceiptDetails == null)
                                {
                                    result.ResultStatus = -1;
                                    result.Message = "当前流水未回执,不能补零";
                                    return result;
                                }

                                decimal sumQtyMiss = stockReceiptDetails.Sum(temp => temp.QtyMiss);
                                detail.IntegerAmount = sumQtyMiss;
                                detail.NetAmount = sumQtyMiss;
                            }
                            //else
                            //{
                            //    detail.IntegerAmount = stockLog.GrossAmount;
                            //    detail.NetAmount = stockLog.NetAmount;
                            //}
                            result = detailDAL.Insert(user, detail);
                            if (result.ResultStatus != 0)
                                return result;
                        }
                    }

                    invoice.InvoiceId = invoiceId;
                    if (result.ResultStatus == 0) result.ReturnValue = invoice;

                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                result.ResultStatus = -1;
                result.Message = ex.Message;
            }

            return result;
        }
Exemplo n.º 48
0
			public OperateData(Operate o, object[] a = null)
			{
				opt = o;
				args = a;
			}
Exemplo n.º 49
0
        public ResultModel UpdateBusinessInvoice(UserModel user, Operate.Model.Invoice invoice, BusinessInvoice invoiceBusiness, List<BusinessInvoiceDetail> details)
        {
            ResultModel result = new ResultModel();

            try
            {
                BusinessInvoiceDAL businessInvoiceDAL = new BusinessInvoiceDAL();
                InvoiceDAL invoiceDAL = new InvoiceDAL();
                BusinessInvoiceDetailDAL detailDAL = new BusinessInvoiceDetailDAL();
                StockReceiptDetailDAL stockReceiptDetailDAL = new StockReceiptDetailDAL();

                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    //验证发票
                    if (invoiceBusiness.BusinessInvoiceId <= 0)
                    {
                        result.Message = "发票不存在";
                        return result;
                    }

                    result = businessinvoiceDAL.Get(user, invoiceBusiness.BusinessInvoiceId);
                    if (result.ResultStatus != 0)
                        return result;

                    BusinessInvoice resultBusinessInvoice = result.ReturnValue as BusinessInvoice;
                    if (resultBusinessInvoice == null || resultBusinessInvoice.BusinessInvoiceId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "发票不存在";
                        return result;
                    }

                    //更新发票
                    resultBusinessInvoice.IntegerAmount = invoiceBusiness.IntegerAmount;
                    resultBusinessInvoice.NetAmount = invoiceBusiness.NetAmount;
                    resultBusinessInvoice.VATRatio = invoiceBusiness.VATRatio;
                    resultBusinessInvoice.VATBala = invoiceBusiness.VATBala;
                    resultBusinessInvoice.UnitPrice = invoiceBusiness.UnitPrice;

                    resultBusinessInvoice.Status = StatusEnum.已录入;

                    result = businessinvoiceDAL.Update(user, resultBusinessInvoice);
                    if (result.ResultStatus != 0)
                        return result;

                    //获取发票主表
                    result = invoiceDAL.Get(user, resultBusinessInvoice.InvoiceId);
                    if (result.ResultStatus != 0)
                        return result;

                    Operate.Model.Invoice resultInvoice = result.ReturnValue as Operate.Model.Invoice;
                    if (resultInvoice == null || resultInvoice.InvoiceId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "发票不存在";
                        return result;
                    }

                    //更新发票
                    resultInvoice.InvoiceDate = invoice.InvoiceDate;
                    resultInvoice.InvoiceName = invoice.InvoiceName;
                    resultInvoice.InvoiceBala = invoice.InvoiceBala;
                    resultInvoice.OutCorpId = invoice.OutCorpId;
                    resultInvoice.InCorpId = invoice.InCorpId;
                    resultInvoice.Memo = invoice.Memo;

                    result = invoiceDAL.Update(user, resultInvoice);
                    if (result.ResultStatus != 0)
                        return result;

                    //获取发票明细
                    result = detailDAL.Load(user, resultBusinessInvoice.BusinessInvoiceId);
                    if (result.ResultStatus != 0)
                        return result;

                    List<BusinessInvoiceDetail> resultDetails = result.ReturnValue as List<BusinessInvoiceDetail>;
                    if (resultDetails == null)
                    {
                        result.ResultStatus = -1;
                        result.Message = "获取发票明细失败";
                        return result;
                    }

                    //作废发票明细
                    foreach (BusinessInvoiceDetail detail in resultDetails)
                    {
                        if (detail.DetailStatus == StatusEnum.已生效)
                            detail.DetailStatus = StatusEnum.已录入;

                        result = detailDAL.Invalid(user, detail);
                        if (result.ResultStatus != 0)
                            return result;
                    }

                    //新增发票明细
                    StockLogDAL stockLogDAL = new StockLogDAL();
                    StockDAL stockDAL = new StockDAL();
                    foreach (BusinessInvoiceDetail detail in details)
                    {
                        if (detail.NetAmount != 0 && detail.StockId > 0)
                        {
                            //验证库存
                            result = stockDAL.Get(user, detail.StockId);
                            if (result.ResultStatus != 0)
                                return result;
                            Stock stock = result.ReturnValue as Stock;
                            if (stock == null || stock.StockId <= 0)
                            {
                                result.ResultStatus = -1;
                                result.Message = "发票库存获取失败";
                                return result;
                            }

                            //验证库存流水
                            result = stockLogDAL.Get(user, detail.StockLogId);
                            if (result.ResultStatus != 0)
                                return result;

                            StockLog stockLog = result.ReturnValue as StockLog;
                            if (stockLog == null || stockLog.StockLogId <= 0)
                            {
                                result.ResultStatus = -1;
                                result.Message = "新增发票流水获取失败";
                                return result;
                            }

                            //基本验证
                            if (stockLog.StockId != stock.StockId)
                            {
                                result.ResultStatus = -1;
                                result.Message = "库存与库存流水不匹配";
                                return result;
                            }

                            //验证流水合约与发票合约是否相同
                            if (stockLog.SubContractId != resultBusinessInvoice.SubContractId)
                            {
                                result.ResultStatus = -1;
                                result.Message = "合约与库存流水不匹配";
                                return result;
                            }

                            detail.DetailStatus = StatusEnum.已生效;
                            detail.InvoiceId = resultInvoice.InvoiceId;
                            detail.BusinessInvoiceId = resultBusinessInvoice.BusinessInvoiceId;
                            detail.StockId = stockLog.StockId;
                            detail.StockLogId = stockLog.StockLogId;

                            if (resultInvoice.InvoiceType == (int)InvoiceTypeEnum.SuppleFinalInvoice)
                            {
                                //获取当前流水回执信息
                                result = stockReceiptDetailDAL.LoadByStockLogId(user, stockLog.StockLogId);
                                List<StockReceiptDetail> stockReceiptDetails = result.ReturnValue as List<StockReceiptDetail>;
                                if (stockReceiptDetails == null)
                                {
                                    result.ResultStatus = -1;
                                    result.Message = "当前流水未回执,不能补零";
                                    return result;
                                }

                                decimal sumQtyMiss = stockReceiptDetails.Sum(temp => temp.QtyMiss);
                                detail.IntegerAmount = sumQtyMiss;
                                detail.NetAmount = sumQtyMiss;
                            }
                            else
                            {
                                detail.IntegerAmount = stockLog.GrossAmount;
                                detail.NetAmount = stockLog.NetAmount;
                            }

                            result = detailDAL.Insert(user, detail);
                            if (result.ResultStatus != 0)
                                return result;
                        }
                    }

                    if (result.ResultStatus == 0)
                        result.ReturnValue = resultInvoice;
                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                result.ResultStatus = -1;
                result.Message = ex.Message;
            }

            return result;
        }
Exemplo n.º 50
0
        public ResultModel UpdateProvisional(UserModel user, Operate.Model.Invoice invoice, BusinessInvoice provisionalInvoice, List<BusinessInvoiceDetail> details)
        {
            ResultModel result = new ResultModel();

            StockLogDAL stockLogDAL = new StockLogDAL();

            foreach (BusinessInvoiceDetail detail in details)
            {
                detail.UnitPrice = provisionalInvoice.UnitPrice;
                result = stockLogDAL.Get(user, detail.StockLogId);
                if (result.ResultStatus != 0)
                    return result;

                StockLog stockLog = result.ReturnValue as StockLog;
                if (stockLog == null || stockLog.StockLogId <= 0)
                {
                    result.ResultStatus = -1;
                    result.Message = "当前合约不存在该笔库存";
                    return result;
                }
                detail.IntegerAmount = stockLog.GrossAmount;
            }
            provisionalInvoice.IntegerAmount = details.Sum(temp => temp.IntegerAmount);

            result = this.UpdateBusinessInvoice(user, invoice, provisionalInvoice, details);

            return result;
        }
Exemplo n.º 51
0
 public abstract double Operate(Operate operate);
Exemplo n.º 52
0
        public ResultModel UpdateDirect(UserModel user, Operate.Model.Invoice invoice, BusinessInvoice invoiceBusiness, List<BusinessInvoiceDetail> details)
        {
            ResultModel result = new ResultModel();
            ContractSubDAL subDAL = new ContractSubDAL();
            result = subDAL.Get(user, invoiceBusiness.SubContractId);
            if (result.ResultStatus != 0)
                return result;

            ContractSub sub = result.ReturnValue as ContractSub;
            if (sub == null || sub.SubId <= 0)
            {
                result.ResultStatus = -1;
                result.Message = "子合约不存在";
                return result;
            }

            StockLogDAL stockLogDAL = new StockLogDAL();
            //明细表数据:毛重、金额计算
            foreach (BusinessInvoiceDetail detail in details)
            {
                detail.Bala = Math.Round(detail.NetAmount * detail.UnitPrice, 2, MidpointRounding.AwayFromZero);

                if (sub.TradeBorder == (int)TradeBorderEnum.内贸)
                {
                    //内贸毛重==净重
                    detail.IntegerAmount = detail.NetAmount;
                }
                else
                {
                    //整笔开票情况下,外贸毛重等于库存流水毛重;分笔开票情况下,等于净重。
                    result = stockLogDAL.Get(user, detail.StockLogId);
                    if (result.ResultStatus != 0)
                        return result;

                    StockLog stockLog = result.ReturnValue as StockLog;
                    if (stockLog == null || stockLog.StockLogId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "当前合约不存在该笔库存";
                        return result;
                    }

                    if (stockLog.NetAmount == detail.NetAmount)
                    {
                        detail.IntegerAmount = stockLog.GrossAmount;
                    }
                    else
                    {
                        detail.IntegerAmount = detail.NetAmount;
                    }
                }
            }

            //主表数据:毛重、净重、均价、总额计算
            decimal sumGrossAmount = details.Sum(temp => temp.IntegerAmount);
            invoiceBusiness.IntegerAmount = sumGrossAmount;

            decimal sumNetAmount = details.Sum(temp => temp.NetAmount);
            if (sumNetAmount != invoiceBusiness.NetAmount)
            {
                result.ResultStatus = -1;
                result.Message = "明细净重之和与总净重不相等";
                return result;
            }

            decimal sumBala = details.Sum(temp => temp.Bala);
            if (Math.Abs(sumBala - invoice.InvoiceBala) >=1)
            {
                result.ResultStatus = -1;
                result.Message = "明细金额之和与总金额不相等";
                return result;
            }

            decimal avgPrice = Math.Round(sumBala / sumNetAmount, 4, MidpointRounding.AwayFromZero);
            if (avgPrice != invoiceBusiness.UnitPrice)
            {
                result.ResultStatus = -1;
                result.Message = "计算均价错误";
                return result;
            }

            return this.UpdateBusinessInvoice(user, invoice, invoiceBusiness, details);
            //ResultModel result = new ResultModel();

            //try
            //{
            //    DAL.BusinessInvoiceDAL businessInvoiceDAL = new BusinessInvoiceDAL();
            //    NFMT.Operate.DAL.InvoiceDAL invoiceDAL = new Operate.DAL.InvoiceDAL();
            //    DAL.BusinessInvoiceDetailDAL detailDAL = new BusinessInvoiceDetailDAL();

            //    using (System.Transactions.TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
            //    {
            //        //验证发票
            //        if (invoiceBusiness.BusinessInvoiceId <= 0)
            //        {
            //            result.Message = "直发票不存在";
            //            return result;
            //        }

            //        result = businessinvoiceDAL.Get(user, invoiceBusiness.BusinessInvoiceId);
            //        if (result.ResultStatus != 0)
            //            return result;

            //        NFMT.Invoice.Model.BusinessInvoice resultBusinessInvoice = result.ReturnValue as NFMT.Invoice.Model.BusinessInvoice;
            //        if (resultBusinessInvoice == null || resultBusinessInvoice.BusinessInvoiceId <= 0)
            //        {
            //            result.ResultStatus = -1;
            //            result.Message = "发票不存在";
            //            return result;
            //        }

            //        //更新发票
            //        resultBusinessInvoice.IntegerAmount = invoiceBusiness.IntegerAmount;
            //        resultBusinessInvoice.NetAmount = invoiceBusiness.NetAmount;
            //        resultBusinessInvoice.VATRatio = invoiceBusiness.VATRatio;
            //        resultBusinessInvoice.VATBala = invoiceBusiness.VATBala;
            //        resultBusinessInvoice.UnitPrice = invoiceBusiness.UnitPrice;

            //        resultBusinessInvoice.Status = StatusEnum.已录入;

            //        result = businessinvoiceDAL.Update(user, resultBusinessInvoice);
            //        if (result.ResultStatus != 0)
            //            return result;

            //        //获取发票主表
            //        result = invoiceDAL.Get(user, resultBusinessInvoice.InvoiceId);
            //        if (result.ResultStatus != 0)
            //            return result;

            //        NFMT.Operate.Model.Invoice resultInvoice = result.ReturnValue as NFMT.Operate.Model.Invoice;
            //        if (resultInvoice == null || resultInvoice.InvoiceId <= 0)
            //        {
            //            result.ResultStatus = -1;
            //            result.Message = "发票不存在";
            //            return result;
            //        }

            //        //更新发票
            //        resultInvoice.InvoiceDate = invoice.InvoiceDate;
            //        resultInvoice.InvoiceName = invoice.InvoiceName;
            //        resultInvoice.InvoiceBala = invoice.InvoiceBala;
            //        resultInvoice.OutCorpId = invoice.OutCorpId;
            //        resultInvoice.InCorpId = invoice.InCorpId;
            //        resultInvoice.Memo = invoice.Memo;

            //        result = invoiceDAL.Update(user, resultInvoice);
            //        if (result.ResultStatus != 0)
            //            return result;

            //        //获取发票明细
            //        result = detailDAL.Load(user, resultBusinessInvoice.BusinessInvoiceId);
            //        if (result.ResultStatus != 0)
            //            return result;

            //        List<Model.BusinessInvoiceDetail> resultDetails = result.ReturnValue as List<Model.BusinessInvoiceDetail>;
            //        if (resultDetails == null)
            //        {
            //            result.ResultStatus = -1;
            //            result.Message = "获取发票明细失败";
            //            return result;
            //        }

            //        //作废发票明细
            //        foreach (Model.BusinessInvoiceDetail detail in resultDetails)
            //        {
            //            if (detail.DetailStatus == StatusEnum.已生效)
            //                detail.DetailStatus = StatusEnum.已录入;

            //            result = detailDAL.Invalid(user, detail);
            //            if (result.ResultStatus != 0)
            //                return result;
            //        }

            //        //新增发票明细
            //        foreach (Model.BusinessInvoiceDetail detail in details)
            //        {
            //            if (detail.NetAmount > 0 && detail.Bala > 0 && detail.StockId > 0)
            //            {
            //                detail.DetailStatus = StatusEnum.已生效;
            //                detail.InvoiceId = invoice.InvoiceId;
            //                detail.BusinessInvoiceId = invoiceBusiness.BusinessInvoiceId;
            //                result = detailDAL.Insert(user, detail);
            //                if (result.ResultStatus != 0)
            //                    return result;
            //            }
            //        }

            //        scope.Complete();
            //    }
            //}
            //catch (Exception ex)
            //{
            //    result.ResultStatus = -1;
            //    result.Message = ex.Message;
            //}

            //return result;
        }
Exemplo n.º 53
0
        public ResultModel RepoApplyCreateHandle(UserModel user, Operate.Model.Apply apply, RepoApply repoApply, List<RepoApplyDetail> details)
        {
            ResultModel result = new ResultModel();

            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    //写入申请主表
                    NFMT.Operate.DAL.ApplyDAL applyDAL = new Operate.DAL.ApplyDAL();
                    result = applyDAL.Insert(user, apply);
                    if (result.ResultStatus != 0)
                        return result;

                    int applyId = (int)result.ReturnValue;
                    repoApply.ApplyId = applyId;

                    //写入回购申请表
                    NFMT.WareHouse.DAL.RepoApplyDAL repoApplyDAL = new RepoApplyDAL();
                    result = repoApplyDAL.Insert(user, repoApply);
                    if (result.ResultStatus != 0)
                        return result;

                    int repoApplyId = (int)result.ReturnValue;

                    //List<Model.StockExclusive> listStockExclusives = new List<StockExclusive>();

                    //写入回购申请明细表
                    NFMT.WareHouse.DAL.RepoApplyDetailDAL detailDAL = new RepoApplyDetailDAL();
                    foreach (Model.RepoApplyDetail detail in details)
                    {
                        detail.RepoApplyId = repoApplyId;
                        result = detailDAL.Insert(user, detail);
                        if (result.ResultStatus != 0)
                            return result;
                    }
                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
            }
            finally
            {
                if (result.ResultStatus != 0)
                    log.ErrorFormat("{0} {1},类型序号:{2}", user.EmpName, result.Message, result.ReturnValue);
                else if (log.IsInfoEnabled)
                    log.InfoFormat("{0} {1},类型序号:{2}", user.EmpName, result.Message, result.ReturnValue);
            }

            return result;
        }
Exemplo n.º 54
0
        private static System.Net.IPAddress BitOperate(System.Net.IPAddress x, System.Net.IPAddress mask, Operate op)
        {
            byte[] xx = x.GetAddressBytes();
            byte[] mm = mask.GetAddressBytes();
            if (xx.Length != mm.Length)
                throw new ApplicationException("IP地址版本不一致,不能执行“或”操作");
            int i = 0;

            for (i = 0; i < xx.Length; i++)
                xx[i] = op(xx[i], mm[i]);
            return new System.Net.IPAddress(xx);
        }