Ejemplo n.º 1
0
 public static Common.Fish LoadFish(Guid fishGuid)
 {
     Business.Fish fishController = new Business.Fish();
     Common.Fish   fish           = new Common.Fish();
     fishController.Load(fishGuid, fish);
     return(fish);
 }
Ejemplo n.º 2
0
        public static bool InsertFishPayment(Common.Fish fish)
        {
            Business.Fish fishController = new Business.Fish();
            try
            {
                if (fish.Amount <= 0)
                {
                    throw new Exception(Language.GetString("IncorrectAmount"));
                }
                if (Helper.CheckDataConditions(fish.BillNumber).IsEmpty)
                {
                    throw new Exception(Language.GetString("IsEmptyFishNumber"));
                }
                if (Helper.CheckDataConditions(fish.PaymentDate).IsEmpty)
                {
                    throw new Exception(Language.GetString("CompletePaymentDate"));
                }
                if (Fish.IsDuplicateBillNumber(fish.BillNumber))
                {
                    throw new Exception(Language.GetString("IsDuplicateFishNumber"));
                }

                return(fishController.InsertFishPayment(fish));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 3
0
        protected void btnPayment_Click(object sender, EventArgs e)
        {
            Common.Fish fish   = new Common.Fish();
            string      result = string.Empty;

            try
            {
                Common.AccountInformation accountInfo = Facade.AccountInformation.LoadAccountInformation(Helper.GetGuid(hdnAccountGuid.Value));

                Common.User parent = Facade.User.LoadUser(Facade.User.GetGuidOfParent(Guid.Empty, DomainName));

                switch (accountInfo.Bank)
                {
                case (int)Banks.Mellat:
                    BehPardakhtMellat behPardakht = new BehPardakhtMellat();

                    if (Helper.CheckDataConditions(accountInfo.TerminalID).IsEmpty ||
                        Helper.CheckDataConditions(accountInfo.UserName).IsEmpty ||
                        Helper.CheckDataConditions(accountInfo.Password).IsEmpty)
                    {
                        throw new Exception(Language.GetString("OnlineGatewayInfoIncorrect"));
                    }

                    behPardakht.TerminalID  = Helper.GetLong(accountInfo.TerminalID);
                    behPardakht.UserName    = accountInfo.UserName;
                    behPardakht.Password    = accountInfo.Password;
                    behPardakht.Amount      = Helper.GetLong(txtPanelPrice.Text);
                    behPardakht.CallBackUrl = string.Format("{0}/{1}/{2}/{3}/", "http://" + Helper.GetLocalDomain(Request.Url.Authority), "SalePackage", PackageId, (int)Business.Banks.Mellat);
                    string refID = behPardakht.Request(ref result);

                    if (Helper.CheckDataConditions(refID).IsEmpty)
                    {
                        throw new Exception(Language.GetString("DontAccessToOnlineGateway"));
                    }

                    #region InsertFish
                    fish.ReferenceID            = refID;
                    fish.CreateDate             = DateTime.Now;
                    fish.PaymentDate            = DateTime.Now;
                    fish.SmsCount               = 0;
                    fish.Amount                 = Helper.GetDecimal(txtPanelPrice.Text);
                    fish.OrderID                = behPardakht.OrderID.ToString();
                    fish.Type                   = (int)Business.TypeFish.OnLine;
                    fish.Status                 = (int)Business.FishStatus.Checking;
                    fish.AccountInformationGuid = accountInfo.AccountInfoGuid;
                    fish.UserGuid               = UserGuid;
                    Facade.Fish.InsertOnlinePayment(fish);
                    #endregion

                    Page.ClientScript.RegisterClientScriptBlock(typeof(string), "behpardakht", string.Format("<script language=javascript type='text/javascript'>$(function(){{{0}}});</script>", behPardakht.GotoGateway(refID)));
                    break;
                }
            }
            catch (Exception ex)
            {
                lblMessage.Text = ex.Message;
            }
        }
Ejemplo n.º 4
0
		public DataTable gridUserFishes_OnDataBind(string sortField, string searchFiletrs, string toolbarFilters, string userData, int pageNo, int pageSize, ref int resultCount, ref string customData)
		{
			if (!string.IsNullOrEmpty(toolbarFilters))
			{
				JArray array = JArray.Parse(toolbarFilters);
				JObject typeCreditChange = array.Children<JObject>().Where(obj => obj.Property("field").Value.ToString() == "Status" && obj.Property("data").Value.ToString() == "0").FirstOrDefault();
				array.Remove(typeCreditChange);

				toolbarFilters = array.ToString();
			}

			string query = Helper.GenerateQueryFromToolbarFilters(toolbarFilters);

			Common.Fish fish = new Common.Fish();
			fish.UserGuid = UserGuid;
			return Facade.Fish.GetPagedUserFishes(UserGuid,query, sortField, pageNo, pageSize, ref resultCount);
		}
Ejemplo n.º 5
0
        public bool InsertFishPayment(Common.Fish fish)
        {
            Guid guid = Guid.NewGuid();

            return(base.ExecuteSPCommand("InsertFishPayment",
                                         "@Guid", guid,
                                         "@CreateDate", Helper.GetDateTimeForDB(fish.CreateDate),
                                         "@BillNumber", fish.BillNumber,
                                         "@SmsCount", fish.SmsCount,
                                         "@Amount", fish.Amount,
                                         "@PaymentDate", Helper.GetDateTimeForDB(fish.PaymentDate),
                                         "@Description", fish.Description,
                                         "@Type", fish.Type,
                                         "@Status", fish.Status,
                                         "@AccountInformationGuid", fish.AccountInformationGuid,
                                         "@UserGuid", fish.UserGuid));
        }
Ejemplo n.º 6
0
        public static bool ConfirmOnlineFish(Guid userGuid, decimal smsCount, Business.TypeCreditChanges typeCreditChanges,
                                             string descriptionIncrease, Guid fishGuid, long billNumber)
        {
            Business.Fish fishController      = new Business.Fish();
            Common.User   user                = new Common.User();
            string        descriptionDecrease = string.Empty;

            Common.Fish fish = Fish.LoadFish(fishGuid);

            if (fish.Status != (int)Business.FishStatus.Confirmed)
            {
                fishController.BeginTransaction();
                try
                {
                    user = User.LoadUser(userGuid);
                    descriptionDecrease = string.Format(Language.GetString("DecreasePaymentTransaction"), user.UserName, smsCount, billNumber);

                    Common.User parent = User.LoadUser(user.ParentGuid);

                    if (!parent.IsMainAdmin)
                    {
                        Transaction.Decrease(user.ParentGuid, smsCount, typeCreditChanges, descriptionDecrease, fish.FishGuid, fishController.DataAccessProvider);
                    }
                    Guid transactionGuid = Transaction.Increase(userGuid, smsCount, typeCreditChanges, descriptionIncrease, fishGuid, !user.IsFixPriceGroup, fishController.DataAccessProvider);

                    if (!fishController.UpdateOnlineFish(fishGuid, Business.FishStatus.Confirmed, billNumber, transactionGuid))
                    {
                        throw new Exception(Language.GetString("ErrorRecord"));
                    }

                    fishController.CommitTransaction();
                    return(true);
                }
                catch
                {
                    fishController.RollbackTransaction();
                    return(false);
                }
            }
            else
            {
                return(true);
            }
        }
Ejemplo n.º 7
0
        public static bool InsertOnlinePayment(Common.Fish fish)
        {
            Business.Fish fishController = new Business.Fish();

            try
            {
                if (fish.Amount <= 0)
                {
                    throw new Exception(Language.GetString("IncorrectAmount"));
                }

                fishController.InsertOnlinePayment(fish);
                return(true);
            }
            catch
            {
                throw;
            }
        }
Ejemplo n.º 8
0
        protected void btnSaveFishPayment_Click(object sender, EventArgs e)
        {
            bool decreaseTax = true;

            Common.Fish fish = new Common.Fish();
            try
            {
                decimal basePrice = Facade.GroupPrice.GetUserBaseSmsPrice(UserGuid, ParentGuid, Helper.GetLong(txtSmsCount.Text), ref decreaseTax);
                decimal tax       = 0;
                if (decreaseTax)
                {
                    tax = Facade.Transaction.ComputeTax(Helper.GetDecimal(basePrice * Helper.GetInt(txtSmsCount.Text)));
                }

                fish.CreateDate             = DateTime.Now;
                fish.BillNumber             = txtSerialNumber.Text;
                fish.SmsCount               = Helper.GetLong(txtSmsCount.Text);
                fish.Amount                 = Helper.GetDecimal(txtAccountAmount.Text);
                fish.PaymentDate            = DateManager.GetChristianDateForDB(dtpPaymentDate.Value);
                fish.Description            = txtDescription.Text;
                fish.Type                   = (int)TypeFish.Account;
                fish.Status                 = (int)FishStatus.Checking;
                fish.AccountInformationGuid = Helper.GetGuid(drpAccount.SelectedValue);
                fish.UserGuid               = UserGuid;

                if (!Facade.Fish.InsertFishPayment(fish))
                {
                    throw new Exception(Language.GetString("InsertRecord"));
                }

                ClientSideScript = string.Format("saveResult('account','ok','{0}')", Language.GetString("InsertRecord"));
            }
            catch (Exception ex)
            {
                ClientSideScript = string.Format("saveResult('account','error','{0}')", ex.Message);
            }
        }
Ejemplo n.º 9
0
        protected void btnPayment_Click(object sender, EventArgs e)
        {
            Common.Fish fish   = new Common.Fish();
            string      result = string.Empty;

            try
            {
                if (Helper.GetDecimal(txtPrice.Text) == 0)
                {
                    if (!Facade.PrivateNumber.UpdateExpireDate(PrivateNumberGuid, DateTime.Now.AddYears(1)))
                    {
                        throw new Exception(Language.GetString("ErrorRecord"));
                    }

                    Response.Redirect(string.Format("/PageLoader.aspx?c={0}", Helper.Encrypt((int)UserControls.UI_PrivateNumbers_UserPrivateNumber, Session)));
                }

                Common.AccountInformation accountInfo = Facade.AccountInformation.LoadAccountInformation(Helper.GetGuid(hdnAccountGuid.Value));

                Common.User parent = Facade.User.LoadUser(ParentGuid);

                switch (accountInfo.Bank)
                {
                case (int)Banks.Mellat:
                    BehPardakhtMellat behPardakht = new BehPardakhtMellat();

                    if (Helper.CheckDataConditions(accountInfo.TerminalID).IsEmpty ||
                        Helper.CheckDataConditions(accountInfo.UserName).IsEmpty ||
                        Helper.CheckDataConditions(accountInfo.Password).IsEmpty)
                    {
                        throw new Exception(Language.GetString("OnlineGatewayInfoIncorrect"));
                    }

                    behPardakht.TerminalID  = Helper.GetLong(accountInfo.TerminalID);
                    behPardakht.UserName    = accountInfo.UserName;
                    behPardakht.Password    = accountInfo.Password;
                    behPardakht.Amount      = Helper.GetLong(txtPrice.Text);
                    behPardakht.CallBackUrl = string.Format("{0}/{1}/{2}", "http://" + Helper.GetLocalDomain(Request.Url.Authority), "ExtendedNumber", (int)Banks.Mellat);
                    string refID = behPardakht.Request(ref result);

                    if (Helper.CheckDataConditions(refID).IsEmpty)
                    {
                        throw new Exception(Language.GetString("DontAccessToOnlineGateway"));
                    }

                    #region InsertFish
                    fish.ReferenceID            = refID;
                    fish.CreateDate             = DateTime.Now;
                    fish.PaymentDate            = DateTime.Now;
                    fish.SmsCount               = 0;
                    fish.Amount                 = Helper.GetDecimal(txtPrice.Text);
                    fish.OrderID                = behPardakht.OrderID.ToString();
                    fish.Type                   = (int)TypeFish.OnLine;
                    fish.Status                 = (int)FishStatus.Checking;
                    fish.ReferenceGuid          = PrivateNumberGuid;
                    fish.AccountInformationGuid = accountInfo.AccountInfoGuid;
                    fish.UserGuid               = UserGuid;
                    Facade.Fish.InsertOnlinePayment(fish);
                    #endregion

                    Page.ClientScript.RegisterClientScriptBlock(typeof(string), "behpardakht", string.Format("<script language=javascript type='text/javascript'>$(function(){{{0}}});</script>", behPardakht.GotoGateway(refID)));
                    break;
                }
            }
            catch (Exception ex)
            {
                lblMessage.Text = ex.Message;
            }
        }
Ejemplo n.º 10
0
        protected void btnSaveOnlinePayment_Click(object sender, EventArgs e)
        {
            Common.AccountInformation accountInfo = new Common.AccountInformation();
            Common.Fish fish   = new Common.Fish();
            string      result = string.Empty;

            try
            {
                if (rdbMellat.Checked)
                {
                    if (Helper.GetGuid(rdbMellat.Value) == Guid.Empty)
                    {
                        throw new Exception(Language.GetString("AccountInvalid"));
                    }
                    accountInfo = Facade.AccountInformation.LoadAccountInformation(Helper.GetGuid(rdbMellat.Value));
                }
                else if (rdbParsian.Checked)
                {
                    if (Helper.GetGuid(rdbParsian.Value) == Guid.Empty)
                    {
                        throw new Exception(Language.GetString("AccountInvalid"));
                    }
                    accountInfo = Facade.AccountInformation.LoadAccountInformation(Helper.GetGuid(rdbParsian.Value));
                }

                Common.User parent = Facade.User.LoadUser(ParentGuid);
                if (!parent.IsMainAdmin && parent.Credit < Helper.GetLong(txtOnlineSmsCount.Text))
                {
                    throw new Exception(Language.GetString("SystemUnableAssignCredit"));
                }

                switch (accountInfo.Bank)
                {
                case (int)Banks.Mellat:
                    BehPardakhtMellat behPardakht = new BehPardakhtMellat();

                    if (Helper.CheckDataConditions(accountInfo.TerminalID).IsEmpty ||
                        Helper.CheckDataConditions(accountInfo.UserName).IsEmpty ||
                        Helper.CheckDataConditions(accountInfo.Password).IsEmpty)
                    {
                        throw new Exception(Language.GetString("OnlineGatewayInfoIncorrect"));
                    }

                    behPardakht.TerminalID  = Helper.GetLong(accountInfo.TerminalID);
                    behPardakht.UserName    = accountInfo.UserName;
                    behPardakht.Password    = accountInfo.Password;
                    behPardakht.Amount      = Helper.GetLong(txtOnlineAmount.Text);
                    behPardakht.CallBackUrl = string.Format("{0}/{1}/{2}", "http://" + Helper.GetLocalDomain(Request.Url.Authority), "PaymentReport", (int)Arad.SMS.Gateway.Business.Banks.Mellat);
                    string refID = behPardakht.Request(ref result);

                    if (Helper.CheckDataConditions(refID).IsEmpty)
                    {
                        throw new Exception(Language.GetString("DontAccessToOnlineGateway"));
                    }

                    #region InsertFish
                    fish.ReferenceID            = refID;
                    fish.CreateDate             = DateTime.Now;
                    fish.PaymentDate            = DateTime.Now;
                    fish.SmsCount               = Helper.GetLong(txtOnlineSmsCount.Text);
                    fish.Amount                 = Helper.GetDecimal(txtOnlineAmount.Text);
                    fish.OrderID                = behPardakht.OrderID.ToString();
                    fish.Type                   = (int)Arad.SMS.Gateway.Business.TypeFish.OnLine;
                    fish.Status                 = (int)Arad.SMS.Gateway.Business.FishStatus.Checking;
                    fish.AccountInformationGuid = accountInfo.AccountInfoGuid;
                    fish.UserGuid               = UserGuid;
                    Facade.Fish.InsertOnlinePayment(fish);
                    #endregion

                    ClientSideScript = behPardakht.GotoGateway(refID);
                    break;

                case (int)Banks.Parsian:
                    ParsianPaymentGateway parsian = new ParsianPaymentGateway();

                    if (Helper.CheckDataConditions(accountInfo.PinCode).IsEmpty)
                    {
                        throw new Exception(Language.GetString("OnlineGatewayInfoIncorrect"));
                    }

                    parsian.Pin         = accountInfo.PinCode;
                    parsian.Amount      = Helper.GetInt(txtOnlineAmount.Text);
                    parsian.CallBackUrl = string.Format("{0}/{1}/{2}", "http://" + Helper.GetLocalDomain(Request.Url.Authority), "PaymentReport", (int)Arad.SMS.Gateway.Business.Banks.Parsian);
                    string authority = parsian.Request();

                    if (Helper.CheckDataConditions(authority).IsEmpty)
                    {
                        throw new Exception(Language.GetString("DontAccessToOnlineGateway"));
                    }

                    #region InsertFish
                    fish.ReferenceID            = authority;
                    fish.CreateDate             = DateTime.Now;
                    fish.PaymentDate            = DateTime.Now;
                    fish.SmsCount               = Helper.GetLong(txtOnlineSmsCount.Text);
                    fish.Amount                 = Helper.GetDecimal(txtOnlineAmount.Text);
                    fish.OrderID                = parsian.OrderID.ToString();
                    fish.Type                   = (int)TypeFish.OnLine;
                    fish.Status                 = (int)FishStatus.Checking;
                    fish.AccountInformationGuid = accountInfo.AccountInfoGuid;
                    fish.UserGuid               = UserGuid;
                    Facade.Fish.InsertOnlinePayment(fish);
                    #endregion

                    var redirectUrl = string.Format(parsian.PostUrl, authority);
                    //Response.Redirect(redirectUrl, true);

                    Response.Write("<script language='javascript'>self.parent.location='" + redirectUrl + "';</script>");


                    break;
                }
            }
            catch (Exception ex)
            {
                ClientSideScript = string.Format("saveResult('online','error','{0}')", ex.Message);
            }
        }