/// <summary> /// 删除国家 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void gvCountry_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "DelCountry") { int Id = Convert.ToInt32(e.CommandArgument); //Judge the CountryCode whether has operation before delete by Id int getCount = SetRateBLL.CountryCodeWhetherHasOperation(Id); if (getCount > 0) { Page.ClientScript.RegisterStartupScript(GetType(), "", Transforms.ReturnAlert(GetTran("002151", "该国家已经发生了业务,因此不能删除!"))); return; } else { BLL.CommonClass.ChangeLogs cl_h_info = new BLL.CommonClass.ChangeLogs("Country", "Id"); cl_h_info.AddRecord(Id); ///删除指定的国家记录 int delCount = SetRateBLL.DelCountryByID(Id); if (delCount > 0) { cl_h_info.DeletedIntoLogs(BLL.CommonClass.ChangeCategory.company38, Session["Company"].ToString(), BLL.CommonClass.ENUM_USERTYPE.objecttype9); Page.ClientScript.RegisterStartupScript(GetType(), "", Transforms.ReturnAlert(GetTran("002154", "删除国家成功!"))); } else { Page.ClientScript.RegisterStartupScript(GetType(), "", Transforms.ReturnAlert(GetTran("002156", "删除国家失败,请联系管理员!"))); } } GetCountryInfo(); } }
/// <summary> /// 删除汇率记录 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void gvCurrency_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "DelCurrency") { if (SetRateBLL.GetCountryByRateID(Convert.ToInt32(e.CommandArgument)) < 1) { ///删除指定的汇率记录 int delCount = SetRateBLL.DelCurrencyByID(Convert.ToInt32(e.CommandArgument)); if (delCount > 0) { new Languages().RemoveTranslationRecord("Currency", Convert.ToInt32(e.CommandArgument)); Page.ClientScript.RegisterStartupScript(GetType(), "", Transforms.ReturnAlert(GetTran("002077", "删除汇率成功!"))); } else { Page.ClientScript.RegisterStartupScript(GetType(), "", Transforms.ReturnAlert(GetTran("002080", "删除汇率失败,请联系管理员!"))); } } else { Page.ClientScript.RegisterStartupScript(GetType(), "", Transforms.ReturnAlert(GetTran("002083", "删除汇率失败,该汇率已经有相关联的国家!"))); } GetCurrencyInfo(); } }
protected void GetAllCurrencyIDName() { ///获取汇率表中所有的ID和币种名称 DropNewCurrency.DataSource = SetRateBLL.GetAllCurrencyIDName(); DropNewCurrency.DataTextField = "Name"; DropNewCurrency.DataValueField = "ID"; DropNewCurrency.DataBind(); }
/// <summary> /// 添加国家 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnAddNewCountry_Click(object sender, EventArgs e) { ///通过国家名称获取行数 int getCount = SetRateBLL.GetCountryCountByCountryName(CountryBLL.GetCountryName(DropDownList1.SelectedValue)); if (getCount > 0) { Page.ClientScript.RegisterStartupScript(GetType(), "", Transforms.ReturnAlert(GetTran("002142", "国家名称已经存在!"))); return; } getCount = SetRateBLL.GetCountryCountByRateID(Convert.ToInt32(this.DropNewCurrency.SelectedValue)); if (txtCountryCode.Value.Trim() == "") { Page.ClientScript.RegisterStartupScript(GetType(), "", Transforms.ReturnAlert(GetTran("002144", "对不起,国家编码不能为空!"))); return; } else { int ccCount = SetRateBLL.CountryCodeIsExist(txtCountryCode.Value.Trim()); if (ccCount > 0) { Page.ClientScript.RegisterStartupScript(GetType(), "", Transforms.ReturnAlert(GetTran("002145", "对不起,该国家编码已经存在!"))); return; } } ///实例化国家模型 CountryModel countryModel = new CountryModel(); countryModel.CountryCode = txtCountryCode.Value.Trim(); countryModel.CountryForShort = CountryBLL.GetCountryShortName(DropDownList1.SelectedValue); countryModel.Name = CountryBLL.GetCountryName(DropDownList1.SelectedValue); countryModel.RateID = Convert.ToInt32(DropNewCurrency.SelectedItem.Value); ///向国家表中插入相关记录 int addCount = SetRateBLL.AddCountry(countryModel); if (addCount > 0) { Page.ClientScript.RegisterStartupScript(GetType(), "", Transforms.ReturnAlert(GetTran("002146", "添加国家成功!"))); ResetValue(); } else { Page.ClientScript.RegisterStartupScript(GetType(), "", Transforms.ReturnAlert(GetTran("002149", "添加国家失败,请联系管理员!"))); return; } GetAllCurrencyIDName(); GetCountryInfo(); }
/// <summary> /// 导出国家到Excel /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnExcelCountry_Click(object sender, EventArgs e) { DataTable dt = SetRateBLL.OutToExcel_Country(); if (dt.Rows.Count < 1) { Page.ClientScript.RegisterStartupScript(GetType(), "", Transforms.ReturnAlert(GetTran("001712", "没有可以导出的数据!"))); return; } else { Excel.OutToExcel1(dt, GetTran("002157", "国家信息"), new string[] { "CountryCode=" + GetTran("002106", "国家编码"), "CountryForShort=" + GetTran("002107", "国家简称"), "Name=" + GetTran("001026", "国家名称"), "CurrencyName=" + GetTran("002113", "使用币种") }); } }
/// <summary> /// 导出汇率至Excel /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnExcelCurrency_Click(object sender, EventArgs e) { DataTable dt = SetRateBLL.OutToExcel_Currency(); if (dt.Rows.Count < 1) { Page.ClientScript.RegisterStartupScript(GetType(), "", Transforms.ReturnAlert(GetTran("001712", "没有可以导出的数据!"))); return; } else { Excel.OutToExcel(dt, GetTran("002064", "汇率信息"), new string[] { "Name=" + GetTran("002041", "货币名称"), "Rate=" + GetTran("002056", "汇率") }); } }
/// <summary> /// 获取国家信息 /// </summary> private void GetCountryInfo() { ///通过联合查询获取更多国家信息 DataTable dt = SetRateBLL.GetMoreCountryInfo(); ViewState["sortlanguage"] = dt; if (ViewState["sortlanguagestring"] == null) { ViewState["sortlanguagestring"] = "name asc"; } DataView dv = new DataView((DataTable)ViewState["sortlanguage"]); dv.Sort = ViewState["sortlanguagestring"].ToString(); gvCountry.DataSource = dv; gvCountry.DataBind(); Translations(); }
private void BindLanguage() { ddlLanguage.DataSource = SetRateBLL.GetAllLanguageIDName(); ddlLanguage.DataTextField = "Name"; ddlLanguage.DataValueField = "LanguageCode"; ddlLanguage.DataBind(); if (Session["languageCode"] != null) { foreach (ListItem li in ddlLanguage.Items) { if (li.Value == Session["languageCode"].ToString()) { li.Selected = true; break; } } } }
protected void btnUpdateRate_Click(object sender, EventArgs e) { IList <CurrencyModel> list = new List <CurrencyModel>(); string curr = SetRateBLL.GetDefaultCurrency(); foreach (DataRow dr in SetRateBLL.GetAllCurrency().Rows) { CurrencyModel cm = new CurrencyModel(); cm.JianCheng = dr["jiecheng"].ToString(); net.webservicex.www.CurrencyConvertor CC = new net.webservicex.www.CurrencyConvertor(); cm.Rate = CC.ConversionRate((net.webservicex.www.Currency)Enum.Parse(typeof(net.webservicex.www.Currency), cm.JianCheng), (net.webservicex.www.Currency)Enum.Parse(typeof(net.webservicex.www.Currency), curr)); list.Add(cm); } if (SetRateBLL.UpdCurrencyRateAll(list)) { msg = "<script>alert('" + GetTran("006594", "同步成功!") + "');</script>"; GetCurrencyInfo(); } else { msg = "<script>alert('" + GetTran("006595", "同步失败!") + "');</script>"; } }
/// <summary> /// 更新汇率编辑 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void gvCurrency_RowUpdating(object sender, GridViewUpdateEventArgs e) { int index = gvCurrency.EditIndex; int id = Convert.ToInt32(gvCurrency.Rows[index].Cells[1].Text.Trim()); ///通过币种名称联合查询获取行数 int getCount = SetRateBLL.GetMoreCurrencyCountByCurrencyName(gvCurrency.Rows[index].Cells[3].Text.Trim()); if (getCount > 0) { Page.ClientScript.RegisterStartupScript(GetType(), "", Transforms.ReturnAlert(GetTran("002085", "对不起,此货币已经使用,不能修改!"))); return; } int EdCount_Money = 0; EdCount_Money = Permissions.GetPermissions(EnumCompanyPermission.SystemCurrencyRateCountryEdit); if (EdCount_Money.ToString() == "6219") { ///实例化构造函数 ChangeLogs cl = new ChangeLogs("Currency", "ltrim(rtrim(str(ID)))"); TextBox TextBox_rate = (TextBox)gvCurrency.Rows[index].FindControl("TextBox_rate"); cl.AddRecord(id); ///根据汇率ID更改汇率 decimal rate; try { rate = Convert.ToDecimal(TextBox_rate.Text.Trim()); if (rate < 0) { Page.ClientScript.RegisterStartupScript(GetType(), "", Transforms.ReturnAlert(GetTran("006949", "对不起!您输入的汇率不能小于零!"))); return; } } catch { Page.ClientScript.RegisterStartupScript(GetType(), "", Transforms.ReturnAlert(GetTran("002086", "对不起!您输入的汇率格式不正确!"))); return; } int flag = 0; if ((gvCurrency.Rows[index].FindControl("chkFlag") as CheckBox).Checked) { flag = 1; } int updCount = SetRateBLL.UpdCurrencyRateByID(rate, id, flag); if (updCount > 0) { cl.AddRecord(id); cl.ModifiedIntoLogs(ChangeCategory.company36, Session["Company"].ToString(), ENUM_USERTYPE.objecttype9); Page.ClientScript.RegisterStartupScript(GetType(), "", Transforms.ReturnAlert(GetTran("002087", "汇率更新成功!"))); } else { Page.ClientScript.RegisterStartupScript(GetType(), "", Transforms.ReturnAlert(GetTran("002089", "汇率更新失败,请联系管理员!"))); return; } } else { Page.ClientScript.RegisterStartupScript(GetType(), "", Transforms.ReturnAlert(GetTran("002090", "对不起!您没有更新权限!"))); return; } gvCurrency.EditIndex = -1; GetCurrencyInfo(); }