protected void ctlAddLocal_Click(object sender, ImageClickEventArgs e) { if (UIHelper.ParseShort(ctlLocalCurrencyDropdown.SelectedValue) > 0) { DataRow[] rows = PbDataSet.DbPBCurrency.Select(string.Format("CurrencyID='{0}'", UIHelper.ParseShort(ctlLocalCurrencyDropdown.SelectedValue))); if (rows.Length == 0) { DBPbDataSet.DbPBCurrencyRow row = PbDataSet.DbPBCurrency.NewDbPBCurrencyRow(); row.PBID = this.PBID; row.CurrencyID = UIHelper.ParseShort(ctlLocalCurrencyDropdown.SelectedValue); row.UpdBy = UserAccount.UserID; row.UpdDate = DateTime.Now; row.CreBy = UserAccount.UserID; row.CreDate = DateTime.Now; row.UpdPgm = UserAccount.CurrentProgramCode; PbDataSet.DbPBCurrency.AddDbPBCurrencyRow(row); ctlErrorLocalCurrencyLabel.Visible = false; ctlErrorLocalCurrencyLabel.Text = string.Empty; ctlLocalCurrencyDropdown.ResetControl(); } else { ctlErrorLocalCurrencyLabel.Visible = true; ctlErrorLocalCurrencyLabel.Text = "LocalCurrencyIsDuplicate"; } BindLocalCurrency(); } ctlPBUpdatePanel.Update(); }
public void Initialize(string mode, long id) { Mode = mode.ToString(); PbDataSet = new DBPbDataSet(); ctlMainCurrencyDropdown.DataSource = SsDbQueryProvider.DbCurrencyQuery.FindAll(); //GetCurrencyLangByCurrencyID();//currencyId, UserAccount.CurrentLanguageID); ctlMainCurrencyDropdown.DataTextField = "Symbol"; ctlMainCurrencyDropdown.DataValueField = "CurrencyID"; ctlMainCurrencyDropdown.DataBind(); ctlMainCurrencyDropdown.Items.Insert(0, new ListItem("Please Select", string.Empty)); PBID = id; if (mode.Equals(FlagEnum.EditFlag)) { Dbpb pb = ScgDbQueryProvider.DbPBQuery.FindByIdentity(PBID); ctlPBCode.Text = pb.PBCode; ctlPettyCashLimit.Text = UIHelper.BindDecimal(pb.PettyCashLimit.ToString()); ctlSupplementary.Text = pb.Supplementary; ctlActive.Checked = pb.Active; DbCompany company = ScgDbQueryProvider.DbCompanyQuery.getDbCompanyByCompanyCode(pb.CompanyCode); if (company != null) { ctlCompanyField.SetValue(company.CompanyID); } ctlPBEditorGrid.DataCountAndBind(); IList <DbPBCurrency> list = ScgDbQueryProvider.DbPBCurrencyQuery.FindPBCurrencyByPBID(PBID); ctlRepOffice.Checked = pb.RepOffice; if (pb.MainCurrencyID.HasValue && pb.MainCurrencyID.Value != 0) { ctlMainCurrencyDropdown.SelectedValue = pb.MainCurrencyID.ToString(); } //loop add to dataset foreach (DbPBCurrency pbCurrency in list) { DBPbDataSet.DbPBCurrencyRow row = PbDataSet.DbPBCurrency.NewDbPBCurrencyRow(); row.ID = pbCurrency.ID; row.PBID = pbCurrency.PBID; row.CurrencyID = pbCurrency.CurrencyID; row.CreBy = pbCurrency.CreBy; row.CreDate = pbCurrency.CreDate; row.UpdBy = pbCurrency.UpdBy; row.UpdDate = pbCurrency.UpdDate; row.UpdPgm = pbCurrency.UpdPgm; PbDataSet.DbPBCurrency.AddDbPBCurrencyRow(row); } PbDataSet.AcceptChanges(); BindLocalCurrency(); ctlPBUpdatePanel.Update(); } else if (mode.ToString() == FlagEnum.NewFlag) { ResetValue(); ctlCompanyField.ResetValue(); } if (ctlRepOffice.Checked) { ctlMainCurrencyLabel.Visible = true; ctlMainCurrencyDropdown.Visible = true; ctlLocalCurrencyLabel.Visible = true; ctlLocalCurrencyDropdown.Visible = true; ctlAddLocalCurrencyButton.Visible = true; ctlPBLocalCurrencyGridview.Visible = true; } else { ctlMainCurrencyLabel.Visible = false; ctlMainCurrencyDropdown.Visible = false; ctlLocalCurrencyLabel.Visible = false; ctlLocalCurrencyDropdown.Visible = false; ctlAddLocalCurrencyButton.Visible = false; ctlPBLocalCurrencyGridview.Visible = false; } }