Example #1
0
        public static void LoadPosTenderTypeToCombo(ref ComboBox cbo)
        {
            string sql = "SELECT DISTINCT TypeCode FROM PosTenderType WHERE Retired = 0";

            PosTenderTypeEx.LoadCombo(ref cbo, "TypeCode", false, false, "", sql);

            /**
             * SqlCommand cmd = new SqlCommand();
             * cmd.CommandText = sql;
             * cmd.CommandTimeout = ConfigHelper.CommandTimeout;
             * cmd.CommandType = CommandType.Text;
             *
             * Common.ComboList comboList = new Common.ComboList();
             *
             * using (SqlDataReader reader = SqlHelper.Default.ExecuteReader(cmd))
             * {
             *  while (reader.Read())
             *  {
             *      Common.ComboItem cboItem = new Common.ComboItem(reader.GetString(0), Guid.Empty);
             *
             *      comboList.Add(cboItem);
             *  }
             * }
             *
             * cbo.DataSource = comboList;
             * cbo.ValueMember = "Id";
             * cbo.DisplayMember = "Code";
             * cbo.SelectedIndex = 0;
             */
        }
Example #2
0
        private void FillTenderList()
        {
            var where = "TypeName <> ''";
            var orderBy = new string[] { "TypeCode", "TypeName" };

            PosTenderTypeEx.LoadCombo(ref cboTender, "TypeName", true, true, "", where, orderBy);
        }
Example #3
0
 /// <summary>
 /// Returns the values.
 /// </summary>
 /// <param name="typeId">The type id.</param>
 /// <param name="typeCode">The type code.</param>
 /// <param name="currencyCode">The currency code.</param>
 /// <param name="amount">The amount.</param>
 /// <param name="exchangeRate">The exchange rate.</param>
 /// <param name="amtHkd">The amt HKD.</param>
 /// <param name="card">The card.</param>
 /// <param name="authorize">The authorize.</param>
 public void ReturnValues(ref Guid typeId, ref string typeCode, ref string currencyCode, ref string amount, ref string exchangeRate, ref string amtHkd, ref string card, ref string authorize)
 {
     //string sqlWhere = "TypeCode = '" + cboTypeCode.Text + "' AND CurrencyCode = '" + cboCurrencyCode.Text + "'";
     //RT2020.DAL.PosTenderType posTender = RT2020.DAL.PosTenderType.LoadWhere(sqlWhere);
     typeId       = PosTenderTypeEx.GetId(typeCode, currencyCode);
     typeCode     = cboTypeCode.Text;
     currencyCode = cboCurrencyCode.Text;
     amount       = txtAmount.Text;
     exchangeRate = txtXchgRate.Text;
     amtHkd       = txtAmountHkd.Text;
     card         = txtCardChq.Text;
     authorize    = txtAuthorize.Text;
 }
Example #4
0
 /// <summary>
 /// Handles the SelectedIndexChanged event of the cboCurrencyCode control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
 private void cboCurrencyCode_SelectedIndexChanged(object sender, EventArgs e)
 {
     //string sqlWhere = "TypeCode = '" + cboTypeCode.Text + "' AND CurrencyCode = '" + cboCurrencyCode.Text + "'";
     //RT2020.DAL.PosTenderType posType = RT2020.DAL.PosTenderType.LoadWhere(sqlWhere);
     txtXchgRate.Text = PosTenderTypeEx.GetExchageRte(cboTypeCode.Text, cboCurrencyCode.Text).ToString("n4");
 }
        private bool Save()
        {
            decimal numeric = 0;

            if (txtTypeCode.Text.Length == 0)
            {
                errorProvider.SetError(txtTypeCode, "Cannot be blank!");
                return(false);
            }
            else if (!decimal.TryParse(txtExchangeRate.Text, out numeric))
            {
                errorProvider.SetError(txtExchangeRate, Resources.Common.DigitalNeeded);
                return(false);
            }
            else if (!decimal.TryParse(txtChargeRate.Text, out numeric))
            {
                errorProvider.SetError(txtChargeRate, Resources.Common.DigitalNeeded);
                return(false);
            }
            else if (!decimal.TryParse(txtChargeAmount.Text, out numeric))
            {
                errorProvider.SetError(txtChargeAmount, Resources.Common.DigitalNeeded);
                return(false);
            }
            else if (!decimal.TryParse(txtAdditionalMonthlyCharge.Text, out numeric))
            {
                errorProvider.SetError(txtAdditionalMonthlyCharge, Resources.Common.DigitalNeeded);
                return(false);
            }
            else if (!decimal.TryParse(txtMinimumMonthlyCharge.Text, out numeric))
            {
                errorProvider.SetError(txtMinimumMonthlyCharge, Resources.Common.DigitalNeeded);
                return(false);
            }
            else
            {
                errorProvider.SetError(txtTypeCode, string.Empty);
                errorProvider.SetError(txtExchangeRate, string.Empty);
                errorProvider.SetError(txtChargeRate, string.Empty);
                errorProvider.SetError(txtChargeAmount, string.Empty);
                errorProvider.SetError(txtAdditionalMonthlyCharge, string.Empty);
                errorProvider.SetError(txtMinimumMonthlyCharge, string.Empty);

                using (var ctx = new EF6.RT2020Entities())
                {
                    var oPosTenderType = ctx.PosTenderType.Find(_TenderTypeId);
                    if (oPosTenderType == null)
                    {
                        oPosTenderType        = new EF6.PosTenderType();
                        oPosTenderType.TypeId = Guid.NewGuid();
                        if (PosTenderTypeEx.IsTypeCodeInUse(txtTypeCode.Text.Trim()))
                        {
                            errorProvider.SetError(txtTypeCode, string.Format(Resources.Common.DuplicatedCode, "PoS Tender Type Code"));
                            return(false);
                        }
                        else
                        {
                            oPosTenderType.TypeCode  = txtTypeCode.Text;
                            oPosTenderType.CreatedBy = ConfigHelper.CurrentUserId;
                            oPosTenderType.CreatedOn = DateTime.Now;
                            errorProvider.SetError(txtTypeCode, string.Empty);
                        }
                        ctx.PosTenderType.Add(oPosTenderType);
                    }
                    oPosTenderType.TypeName     = txtTypeName.Text;
                    oPosTenderType.TypeName_Chs = txtTypeNameAlt1.Text;
                    oPosTenderType.TypeName_Cht = txtTypeNameAlt2.Text;

                    oPosTenderType.CurrencyCode            = cboCurrency.Text;
                    oPosTenderType.ExchangeRate            = (txtExchangeRate.Text.Length == 0) ? 0 : Convert.ToDecimal(txtExchangeRate.Text);
                    oPosTenderType.DownloadToPOS           = chkDownloadToPoS.Checked;
                    oPosTenderType.ChargeRate              = (txtChargeRate.Text.Length == 0) ? 0 : Convert.ToDecimal(txtChargeRate.Text);
                    oPosTenderType.ChargeAmount            = (txtChargeAmount.Text.Length == 0) ? 0 : Convert.ToDecimal(txtChargeAmount.Text);
                    oPosTenderType.AdditionalMonthlyCharge = (txtAdditionalMonthlyCharge.Text.Length == 0) ? 0 : Convert.ToDecimal(txtAdditionalMonthlyCharge.Text);
                    oPosTenderType.MinimumMonthlyCharge    = (txtMinimumMonthlyCharge.Text.Length == 0) ? 0 : Convert.ToDecimal(txtMinimumMonthlyCharge.Text);

                    oPosTenderType.ModifiedBy = ConfigHelper.CurrentUserId;
                    oPosTenderType.ModifiedOn = DateTime.Now;

                    ctx.SaveChanges();
                }
                return(true);
            }
        }