Esempio n. 1
0
        //InSertAllSetting
        private int InSertAllSetting(DataTable tb_setting)
        {
            int result = 0;

            foreach (DataRow datarow in tb_setting.Rows)
            {
                if (datarow[0].ToString() != "")
                {
                    EC_tb_Setting ec_tb_setting = new EC_tb_Setting();
                    ec_tb_setting.SettingID = Convert.ToInt32(datarow[0].ToString());
                    ec_tb_setting.Currency  = datarow[1].ToString();
                    ec_tb_setting.TaxRate   = Convert.ToDecimal(datarow[2].ToString());
                    ec_tb_setting.Active    = Convert.ToInt32(datarow[3].ToString());
                    ec_tb_setting.Version   = Convert.ToInt32(datarow[4].ToString());

                    if (bus_tb_setting.InsertSetting(ec_tb_setting, StaticClass.GeneralClass.flag_database_type_general) == 1)
                    {
                        result++;
                    }
                }
            }
            return(result);
        }
Esempio n. 2
0
        //btnAdd_Click
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (txbCurrency.Text.Trim() == "")
                {
                    tblNotification.Text = FindResource("currency_null").ToString();
                    return;
                }

                if (txbTaxRate.Text.Trim() == "")
                {
                    tblNotification.Text = FindResource("tax_rate_null").ToString();
                    return;
                }

                decimal taxrate = 0;
                if (!decimal.TryParse(txbTaxRate.Text.Trim(), NumberStyles.AllowDecimalPoint, StaticClass.GeneralClass.app_settings["decimalSeparator"].ToString() == "0" ? new CultureInfo("en-US") : new CultureInfo("fr-FR"), out taxrate))
                {
                    tblNotification.Text = FindResource("tax_rate_invalid").ToString();
                    return;
                }

                if (taxrate >= 100 || taxrate < 0)
                {
                    tblNotification.Text = FindResource("tax_rate_value_invalid").ToString();
                    return;
                }

                int version = 1;
                if (int.TryParse(txbVersion.Text.Trim().ToString(), out version) == false)
                {
                    tblNotification.Text = FindResource("version_invalid").ToString();
                    return;
                }
                else
                {
                    EC_tb_Setting setting = new EC_tb_Setting();
                    setting.Currency = StaticClass.GeneralClass.HandlingSpecialCharacter(txbCurrency.Text.Trim().ToString());
                    setting.TaxRate  = taxrate;
                    setting.Version  = version;
                    if (chkActive.IsChecked == true)
                    {
                        setting.Active = 1;
                        bus_tb_setting.UpdateSettingActive();
                    }
                    else
                    {
                        setting.Active = 0;
                    }

                    if (bus_tb_setting.InsertSetting(setting, StaticClass.GeneralClass.flag_database_type_general) == 1)
                    {
                        if (setting.Active == 1)
                        {
                            DataTable tb_setting = bus_tb_setting.GetSetting("WHERE [SettingID] = (SELECT MAX([SettingID]) FROM [tb_Currency])");
                            if (tb_setting.Rows.Count == 1)
                            {
                                StaticClass.GeneralClass.flag_add_edit_setting_general = true;
                                StaticClass.GeneralClass.settingid_setting_general     = Convert.ToInt32(tb_setting.Rows[0]["SettingID"].ToString());
                                StaticClass.GeneralClass.currency_setting_general      = tb_setting.Rows[0]["Currency"].ToString() + " ";
                                StaticClass.GeneralClass.taxrate_setting_general       = Convert.ToDecimal(tb_setting.Rows[0]["TaxRate"].ToString());
                                StaticClass.GeneralClass.active_setting_general        = Convert.ToInt32(tb_setting.Rows[0]["Active"].ToString());
                                StaticClass.GeneralClass.version_setting_general       = Convert.ToInt32(tb_setting.Rows[0]["Version"].ToString());
                            }
                        }

                        if (add_delegate != null)
                        {
                            add_delegate();
                            this.Close();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                tblNotification.Text = ex.Message;
            }
        }