public async Task <IActionResult> OnPostAsync()
        {
            var user = await _userManager.GetUserAsync(User);

            if (user == null || !user.StudentIdentityConfirmed || user.Id != PostUserId)
            {
                return(RedirectToPage("Index"));
            }
            if (SaleInput.GoodsPhoto == null)
            {
                PostUserId = user.Id;
                ModelState.AddModelError("", "请选择一张图片");
                return(Page());
            }
            if (SaleInput.GoodsPhoto.Length == 0)
            {
                PostUserId = user.Id;
                ModelState.AddModelError("", "请选择一张图片");
                return(Page());
            }
            var uploadFolder   = Path.Combine(_iWebHostEnvironment.WebRootPath, "images", "distribute");
            var uploadFileName = Guid.NewGuid() + Path.GetExtension(SaleInput.GoodsPhoto.FileName);
            var filePath       = Path.Combine(uploadFolder, uploadFileName);

            if (!Directory.Exists(uploadFolder))
            {
                Directory.CreateDirectory(uploadFolder);
            }
            await SaleInput.GoodsPhoto.CopyToAsync(new FileStream(filePath, FileMode.Create));

            var time = DateTime.UtcNow;
            var post = new SecondHand
            {
                Id                = Guid.NewGuid().ToString(),
                GoodsPhotoUrl     = "/images/distribute/" + uploadFileName,
                GoodsName         = SaleInput.GoodsName,
                GoodsPrice        = SaleInput.GoodsPrice,
                GoodsQuality      = SaleInput.GoodsQuality,
                GoodsDescription  = SaleInput.GoodsDescription,
                TypeId            = "00000000-0000-0000-0000-000000000003",
                PostUserId        = user.Id,
                PostTime          = time,
                InvalidTime       = time.AddDays(2.0),
                MissionNotes      = SaleInput.MissionNotes,
                PosterAddress1    = SaleInput.PosterAddress1,
                PosterAddress2    = SaleInput.PosterAddress2,
                PosterPhoneNumber = SaleInput.PosterPhoneNumber,
            };
            var result = _fleaMarket.Post(post);

            if (result == 1)
            {
                StatusMessage = "Success:发布成功";
                return(RedirectToPage("/Sale", new { Area = "Posts", postId = post.Id }));
            }
            StatusMessage = "Error:发布失败";
            return(RedirectToPage());
        }
 public AnalogClock(double centerX, double centerY, MinuteHand minute, SecondHand second, HourHand hour,
                    Ticks ticks, Face face)
 {
     CenterX = centerX;
     CenterY = centerY;
     Minute  = minute;
     Second  = second;
     Hour    = hour;
     ticks.Set5minTicks(CenterX, CenterX, CenterY);
     face.SetFace();
 }
        public async Task <IActionResult> OnPostEditMissionAsync()
        {
            var user = await _userManager.GetUserAsync(User);

            if (user == null || !user.StudentIdentityConfirmed || user.Id != PostUserId || PostId == null)
            {
                return(RedirectToPage("Index"));
            }
            var post = new SecondHand();

            if (SaleInput.GoodsPhoto != null && SaleInput.GoodsPhoto.Length != 0)
            {
                var uploadFolder   = Path.Combine(_iWebHostEnvironment.WebRootPath, "images", "distribute");
                var uploadFileName = Guid.NewGuid() + Path.GetExtension(SaleInput.GoodsPhoto.FileName);
                var filePath       = Path.Combine(uploadFolder, uploadFileName);
                if (!Directory.Exists(uploadFolder))
                {
                    Directory.CreateDirectory(uploadFolder);
                }
                await SaleInput.GoodsPhoto.CopyToAsync(new FileStream(filePath, FileMode.Create));

                post.GoodsPhotoUrl = "/images/distribute/" + uploadFileName;
            }
            else
            {
                post.GoodsPhotoUrl = GoodsUrl;
            }
            var time = DateTime.UtcNow;

            post.Id                = PostId;
            post.GoodsName         = SaleInput.GoodsName;
            post.GoodsPrice        = SaleInput.GoodsPrice;
            post.GoodsQuality      = SaleInput.GoodsQuality;
            post.GoodsDescription  = SaleInput.GoodsDescription;
            post.TypeId            = "00000000-0000-0000-0000-000000000003";
            post.PostUserId        = user.Id;
            post.PostTime          = time;
            post.InvalidTime       = time.AddDays(2.0);
            post.MissionNotes      = SaleInput.MissionNotes;
            post.PosterAddress1    = SaleInput.PosterAddress1;
            post.PosterAddress2    = SaleInput.PosterAddress2;
            post.PosterPhoneNumber = SaleInput.PosterPhoneNumber;
            var result = _fleaMarket.Update(post);

            if (result == 1)
            {
                StatusMessage = "Success:修改成功";
                return(RedirectToPage("/Sale", new { Area = "Posts", postId = post.Id }));
            }
            StatusMessage = "Success:修改失败";
            return(Page());
        }
    private void UpdateClock()
    {
        float hour, min, sec;

        hour = dayNightCycle.getTime();
        hour = hour / 3600;

        min = dayNightCycle.getTime();
        min = min / 60;

        sec = dayNightCycle.getTime();

        if (hour > hourTime + 1)
        {
            float temp = hour;
            hour -= hourTime;
            HourHand.Rotate(0, 0, 30 * hour);
            hourTime = temp;
        }

        if (min > minuteTime + 1)
        {
            float temp = min;
            min -= minuteTime;
            MinuteHand.Rotate(0, 0, 6 * min);
            minuteTime = temp;
        }

        if (sec > secondsTime + 1)
        {
            float temp = sec;
            sec -= secondsTime;
            SecondHand.Rotate(0, 0, 6 * sec);
            secondsTime = temp;
        }

        if (dayNightCycle.getDay() > day)
        {
            hourTime    = dayNightCycle.getTime() / 3600;
            minuteTime  = dayNightCycle.getTime() / 60;
            secondsTime = dayNightCycle.getTime();
            HourHand.Rotate(0, 0, 30);
            day++;
        }
    }
Beispiel #5
0
        private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
        {
            SecondHand.Begin();
            LongHand.Begin();
            HourHand.Begin();

            int second = DateTime.Now.Second;

            SecondHand.Seek(new TimeSpan(0, 0, second));

            int minutes = DateTime.Now.Minute;

            LongHand.Seek(new TimeSpan(0, minutes, second));

            int hour = DateTime.Now.Hour;

            HourHand.Seek(new TimeSpan(hour, minutes, second));
        }
        /// <summary>
        /// használt cikk beállítása
        /// </summary>
        /// <param name="secondHand"></param>
        /// <param name="productName"></param>
        /// <param name="productNameEnglish"></param>
        /// <param name="partNumber"></param>
        /// <param name="itemState"></param>
        public void SetSecondHandProduct(SecondHand secondHand, string productName, string productNameEnglish, string partNumber, ItemState itemState)
        {
            this.ProductId = secondHand.ProductId;

            this.ProductName = productName;

            this.ProductNameEnglish = productNameEnglish;

            this.PartNumber = partNumber;

            this.CustomerPrice = secondHand.Price;

            this.Stock = 0;         // secondHand.Quantity;

            this.ItemState = itemState;

            this.DataAreaId = secondHand.DataAreaId;

            this.ConfigId = secondHand.ConfigId;

            this.InventLocationId = secondHand.InventLocationId;

            this.Quantity = 1;          
        }
Beispiel #7
0
        public static MsCrmResult UpdateOrCreateSecondHand(SecondHand _secondHand, IOrganizationService service, SqlDataAccess sda)
        {
            MsCrmResult returnValue = new MsCrmResult();

            try
            {
                Entity ent = new Entity("new_resalerecord");
                ent["new_name"] = _secondHand.Name;
                if (_secondHand.Contact != null)
                {
                    ent["new_contactid"] = _secondHand.Contact;
                }
                if (_secondHand.Account != null)
                {
                    ent["new_accountid"] = _secondHand.Account;
                }
                if (_secondHand.Owner != null)
                {
                    ent["ownerid"] = _secondHand.Owner;
                }
                if (_secondHand.Product != null)
                {
                    ent["new_productid"] = _secondHand.Product;
                }

                if (_secondHand.SecondHandAmount != null)
                {
                    ent["new_salesfee"] = new Money(_secondHand.SecondHandAmount.Value);
                }
                if (_secondHand.Currency != null)
                {
                    ent["transactioncurrencyid"] = _secondHand.Currency;
                }
                if (_secondHand.CommissionAmount != null)
                {
                    ent["new_commission"] = new Money(_secondHand.CommissionAmount.Value);
                }



                if (_secondHand.Currency != null)
                {
                    ent["transactioncurrencyid"] = new EntityReference("transactioncurrency", _secondHand.Currency.Id);
                }

                if (_secondHand.Currency != null)
                {
                    ent["transactioncurrencyid"] = new EntityReference("transactioncurrency", _secondHand.Currency.Id);
                }


                if (_secondHand.StatusCode != null)
                {
                    if (_secondHand.StatusCode.Value == (int)SecondHandStatuses.Onaylandi)
                    {
                        ent["new_prepaymentdate"] = DateTime.Now;
                        if (_secondHand.PrePayment.HasValue)
                        {
                            ent["new_resalespreamount"] = new Money(_secondHand.PrePayment.Value);
                        }
                        if (_secondHand.PrePaymentType.HasValue)
                        {
                            ent["new_prepaymenttype"] = new OptionSetValue(_secondHand.PrePaymentType.Value);
                        }
                    }
                }

                if (_secondHand.SecondHandId.HasValue)
                {
                    ent.Id = _secondHand.SecondHandId.Value;
                    service.Update(ent);
                    returnValue.CrmId   = _secondHand.SecondHandId.Value;
                    returnValue.Success = true;
                    returnValue.Result  = "2.El Satış kaydı başarıyla güncelleştirildi.";
                }
                else
                {
                    returnValue.CrmId   = service.Create(ent);
                    returnValue.Success = true;
                    returnValue.Result  = "2.El Satış kaydı başarıyla oluşturuldu.";
                }
            }
            catch (Exception ex)
            {
                returnValue.Success = false;
                returnValue.Result  = ex.Message;
            }
            return(returnValue);
        }
Beispiel #8
0
        public static MsCrmResultObject GetSecondHandDetail(Guid rentalid, SqlDataAccess sda)
        {
            MsCrmResultObject returnValue = new MsCrmResultObject();

            try
            {
                #region | SQL QUERY |

                string sqlQuery = @"SELECT
									q.new_name,
									q.new_resalerecordId,
									q.new_accountid,
									q.new_accountidName,
									q.new_productid,
									q.new_productidName,
									q.new_contactid,
									q.new_contactidName,
									q.new_resalespreamount,
                                    q.new_commission,
									q.new_salesfee,
									q.TransactionCurrencyId,
									q.TransactionCurrencyIdName,
                                    q.new_prepaymentdate,
                                    q.new_prepaymenttype,
									q.OwnerId, 
									q.OwnerIdName,
									p.new_projectid,
									p.new_projectidName,
                                    p.new_paymentofhire,
                                    p.TransactionCurrencyId as pCurrencyId,
									p.TransactionCurrencyIdName as pCurrencyName,
                                    q.new_prepaymentdate,
                                    q.new_prepaymenttype,
                                    smStateCode.AttributeValue AS StateCode,
                                    smStateCode.Value AS StateValue,

                                    smStatusCode.AttributeValue AS StatusCode,
                                    smStatusCode.Value AS StatusValue,

									prodStatusCode.Value as pStatusName,
									prodStatusCode.AttributeValue as pStatusCode

                                FROM
                                new_resalerecord AS q (NOLOCK)
	                                JOIN
		                                StringMap AS smStateCode (NOLOCK)
			                                ON
			                                smStateCode.ObjectTypeCode=10087
			                                AND
			                                smStateCode.AttributeName='statecode'
			                                AND
			                                smStateCode.AttributeValue=q.StateCode
	                                JOIN
		                                StringMap AS smStatusCode (NOLOCK)
			                                ON
			                                smStatusCode.ObjectTypeCode=10087
			                                AND
			                                smStatusCode.AttributeName='statuscode'
			                                AND
			                                smStatusCode.AttributeValue=q.StatusCode
								     JOIN 
											Product as P 
											ON q.new_productid = p.ProductId
	                               LEFT JOIN
		                                StringMap AS prodStatusCode (NOLOCK)
			                                ON
			                                prodStatusCode.ObjectTypeCode=1024
			                                AND
			                                prodStatusCode.AttributeName='new_usedrentalandsalesstatus'
			                                AND
			                                prodStatusCode.AttributeValue=P.new_usedrentalandsalesstatus
                                WHERE
	                                q.new_resalerecordId=@secondhandid ORDER BY q.CreatedOn DESC"    ;

                #endregion

                SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("@secondhandid", rentalid) };

                DataTable dt = sda.getDataTable(sqlQuery, parameters);

                if (dt.Rows.Count > 0)
                {
                    #region | FILL SECOND HAND INFO |
                    SecondHand _secondHand = new SecondHand();
                    _secondHand.SecondHandId = (Guid)dt.Rows[0]["new_resalerecordId"];
                    _secondHand.Name         = dt.Rows[0]["new_name"].ToString();

                    if (dt.Rows[0]["new_salesfee"] != DBNull.Value)
                    {
                        _secondHand.SecondHandAmount    = (decimal)dt.Rows[0]["new_salesfee"];
                        _secondHand.SecondHandAmountStr = ((decimal)dt.Rows[0]["new_salesfee"]).ToString("N2");
                    }
                    if (dt.Rows[0]["new_paymentofhire"] != DBNull.Value)
                    {
                        _secondHand.ProductAmount    = (decimal)dt.Rows[0]["new_paymentofhire"];
                        _secondHand.ProductAmountStr = ((decimal)dt.Rows[0]["new_paymentofhire"]).ToString("N2");
                    }

                    if (dt.Rows[0]["new_commission"] != DBNull.Value)
                    {
                        _secondHand.CommissionAmount    = (decimal)dt.Rows[0]["new_commission"];
                        _secondHand.CommissionAmountStr = ((decimal)dt.Rows[0]["new_commission"]).ToString("N2");
                    }
                    if (dt.Rows[0]["new_resalespreamount"] != DBNull.Value)
                    {
                        _secondHand.PrePayment    = (decimal)dt.Rows[0]["new_resalespreamount"];
                        _secondHand.PrePaymentStr = ((decimal)dt.Rows[0]["new_resalespreamount"]).ToString("N2");
                    }
                    if (dt.Rows[0]["OwnerId"] != DBNull.Value)
                    {
                        _secondHand.Owner = new EntityReference()
                        {
                            Id = (Guid)dt.Rows[0]["OwnerId"], Name = dt.Rows[0]["OwnerIdName"].ToString(), LogicalName = "systemuser"
                        };
                    }

                    if (dt.Rows[0]["new_contactid"] != DBNull.Value)
                    {
                        _secondHand.Contact = new EntityReference()
                        {
                            Id = (Guid)dt.Rows[0]["new_contactid"], Name = dt.Rows[0]["new_contactidName"].ToString(), LogicalName = "contact"
                        };
                    }
                    if (dt.Rows[0]["new_accountid"] != DBNull.Value)
                    {
                        _secondHand.Contact = new EntityReference()
                        {
                            Id = (Guid)dt.Rows[0]["new_accountid"], Name = dt.Rows[0]["new_accountidName"].ToString(), LogicalName = "account"
                        };
                    }

                    if (dt.Rows[0]["TransactionCurrencyId"] != DBNull.Value)
                    {
                        _secondHand.Currency = new EntityReference()
                        {
                            Id = (Guid)dt.Rows[0]["TransactionCurrencyId"], Name = dt.Rows[0]["TransactionCurrencyIdName"].ToString(), LogicalName = "transactioncurrency"
                        };
                    }
                    if (dt.Rows[0]["pCurrencyId"] != DBNull.Value)
                    {
                        _secondHand.pCurrency = new EntityReference()
                        {
                            Id = (Guid)dt.Rows[0]["pCurrencyId"], Name = dt.Rows[0]["pCurrencyName"].ToString(), LogicalName = "transactioncurrency"
                        };
                    }
                    if (dt.Rows[0]["new_productid"] != DBNull.Value)
                    {
                        _secondHand.Product = new EntityReference()
                        {
                            Id = (Guid)dt.Rows[0]["new_productid"], Name = dt.Rows[0]["new_productidName"].ToString(), LogicalName = "product"
                        };
                    }
                    if (dt.Rows[0]["new_projectid"] != DBNull.Value)
                    {
                        _secondHand.Project = new EntityReference()
                        {
                            Id = (Guid)dt.Rows[0]["new_projectid"], Name = dt.Rows[0]["new_projectidName"].ToString(), LogicalName = "new_project"
                        };
                    }
                    if (dt.Rows[0]["new_prepaymentdate"] != DBNull.Value)
                    {
                        _secondHand.PrePaymentDate    = (DateTime)dt.Rows[0]["new_prepaymentdate"];
                        _secondHand.PrePaymentDateStr = ((DateTime)dt.Rows[0]["new_prepaymentdate"]).ToLocalTime().ToShortDateString();
                    }
                    if (dt.Rows[0]["new_prepaymenttype"] != DBNull.Value)
                    {
                        _secondHand.PrePaymentType = (int)dt.Rows[0]["new_prepaymenttype"];
                    }
                    _secondHand.StateCode = new StringMap()
                    {
                        Name = dt.Rows[0]["StateValue"].ToString(), Value = (int)dt.Rows[0]["StateCode"]
                    };
                    _secondHand.StatusCode = new StringMap()
                    {
                        Name = dt.Rows[0]["StatusValue"].ToString(), Value = (int)dt.Rows[0]["StatusCode"]
                    };
                    _secondHand.pStatusCode = new StringMap()
                    {
                        Name = dt.Rows[0]["pStatusName"].ToString(), Value = (int)dt.Rows[0]["pStatusCode"]
                    };
                    #endregion

                    returnValue.Success      = true;
                    returnValue.ReturnObject = _secondHand;
                }
            }
            catch (Exception ex)
            {
                returnValue.Success = false;
                returnValue.Result  = ex.Message;
            }
            return(returnValue);
        }
Beispiel #9
0
        public static MsCrmResultObject GetCustomerSecondHands(Guid?contactid, Guid?accountid, SqlDataAccess sda)
        {
            MsCrmResultObject returnValue = new MsCrmResultObject();

            try
            {
                #region | SQL QUERY |
                string query = @"SELECT
	                                Q.new_resalerecordId Id
	                                ,SM.Value Status
                                FROM
	                                new_resalerecord Q WITH (NOLOCK)
                                INNER JOIN
	                                StringMap SM WITH (NOLOCK)
	                                ON
	                                {0}
	                                AND
	                                SM.ObjectTypeCode = 10087
	                                AND
	                                SM.AttributeName = 'statuscode'
	                                AND
	                                SM.AttributeValue = Q.StatusCode     
                                    ORDER BY
                                    Q.CreatedOn DESC";
                #endregion
                string customerId = string.Empty;
                if (accountid.HasValue)
                {
                    customerId = string.Format("Q.new_accountid = '{0}'", accountid.Value.ToString());
                }
                if (contactid.HasValue)
                {
                    customerId = string.Format("Q.new_contactid = '{0}'", contactid.Value.ToString());
                }

                DataTable dt = sda.getDataTable(string.Format(query, customerId));

                if (dt != null && dt.Rows.Count > 0)
                {
                    #region | GET SECOND HAND |
                    List <SecondHand> returnList = new List <SecondHand>();

                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        MsCrmResultObject rentalResult = SecondHandHelper.GetSecondHandDetail((Guid)dt.Rows[i]["Id"], sda);

                        if (rentalResult.Success)
                        {
                            SecondHand _secondHand = (SecondHand)rentalResult.ReturnObject;

                            returnList.Add(_secondHand);
                        }
                    }
                    #endregion

                    returnValue.Success      = true;
                    returnValue.ReturnObject = returnList;
                }
                else
                {
                    returnValue.Success = false;
                    returnValue.Result  = "Müşteriye ait Kiralama Kaydı bulunmamaktadır!";
                }
            }
            catch (Exception ex)
            {
                returnValue.Success = false;
                returnValue.Result  = ex.Message;
            }

            return(returnValue);
        }