📄 kjkm_view.aspx.cs
字号:
{
//获取关键字的值,逐个加入对象数组obj
object[] obj = new object[DataTypes.Length];
for (int j=0; j<Pk.Length; j++)
{
obj[j] = ((System.Web.UI.HtmlControls.HtmlInputHidden)_item.FindControl(Pk[j].ToString())).Value; //取各项主关键字
}
ArPks.Insert(n,obj);
n++;
}
}
}
return ArPks;
}
/// **************************************************************************
/// END
/// **************************************************************************
/// **************************************************************************
/// BEIGIN
/// <summary>
/// 会计年度下拉列表框选项改变事件执行函数
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
/// **************************************************************************
private void DropDownList2_SelectedIndexChanged(object sender, System.EventArgs e)
{
ReBind();
}
/// **************************************************************************
/// END
/// **************************************************************************
/// **************************************************************************
/// BEIGIN
/// <summary>
/// 科目类型下拉列表框选项改变事件执行函数
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
/// **************************************************************************
private void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)
{
ReBind();
}
/// **************************************************************************
/// END
/// **************************************************************************
/// **************************************************************************
/// BEIGIN
/// <summary>
/// 根据查询条件重新绑定数据
/// </summary>
/// **************************************************************************
private void ReBind()
{
//如果没有设置会计年度,则不允许查询
// if(DropDownList2.SelectedIndex == 0)
// {
// Prompt.PromptAlert(this,"请选择会计年度!");
// return;
// }
//根据科目类型重新设置查询条件,如果选择全部则全部查询,反之则查询选定类别的会计科目
if(this.DropDownList1.SelectedItem.Value != "0")
{
ViewState["sql"] = "Select * From CW_KJKM Where KJND = '" + DropDownList2.SelectedItem.Value + "' And LB = '" + this.DropDownList1.SelectedItem.Value + "'";;
}
else
{
ViewState["sql"] = "Select * From CW_KJKM Where KJND = '" + DropDownList2.SelectedItem.Value + "'";
}
//根据重新设置的查询条件重新绑定数据
if( CommonService.ReBindDataGrid(this, ViewState["sql"].ToString(), DataGrid1, "Data", Label2, Label3, Label4) == false)
{
Prompt.PromptError(this, "在重新设置查询条件绑定数据时发生异常。");
}
}
/// **************************************************************************
/// END
/// **************************************************************************
/// **************************************************************************
/// BEIGIN
/// <summary>
/// 停用选中的会计科目
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
/// **************************************************************************
private void LinkButton2_Click(object sender, System.EventArgs e)
{
string[] DataTypes = {"string","string"};
string[] pk = {"Hidden1","Hidden2"};
ArrayList al=this.GetPk("CheckBox1",DataTypes,pk,this.DataGrid1);
int i;
object[] obj;
//打开数据库连接
SqlConnection SqlCn = new SqlConnection (com.unicafe.common.Configuration.GetDBConnectionString());
SqlCn.Open();
SqlCommand cmd = SqlCn.CreateCommand();
try
{
//开始事务
SqlTransaction SqlTrans = SqlCn.BeginTransaction();
cmd.Transaction = SqlTrans;
for(i=0;i<al.Count;i++)
{
obj =(object[])al[i];
this.CW_KJKM.KJND=obj[0].ToString();
this.CW_KJKM.KMBM=obj[1].ToString();
this.CW_KJKM = this.CW_KJKMMgr.GetCW_KJKM(this.CW_KJKM.KJND, this.CW_KJKM.KMBM);
this.CW_KJKM.TYBJ = "1";
//检查该会计科目是否允许停用
if(this.CW_KJKMMgr.CheckChild(cmd, this.CW_KJKM.KJND, this.CW_KJKM.KMBM, 1) == true)
{
if(this.CW_KJKMMgr.UpdateCW_KJKM(cmd, this.CW_KJKM) == false) //如果允许则调用修改方法修改停用标记
{
SqlTrans.Rollback();
SqlCn.Close();
Prompt.PromptError(this, "停用操作执行失败。");
return;
}
}
else //检查不通过则给出提示并退出
{
SqlTrans.Rollback();
SqlCn.Close();
Prompt.PromptAlert(this, "某些会计科目还有未停用的下级科目,不能停用。<br>只有下级科目全部停用时,该科目才允许停用。");
return;
}
}
SqlTrans.Commit();
SqlCn.Close();
CommonService.BindDataGrid(this, ViewState["sql"].ToString(), DataGrid1, "Data", true);
}
catch(Exception e1)
{
SqlCn.Close();
Prompt.PromptError(this,"在执行停用会计科目操作时产生异常。");
LogService.Write (e1.Message);
return;
}
}
/// **************************************************************************
/// END
/// **************************************************************************
/// **************************************************************************
/// BEIGIN
/// <summary>
/// 启用选中的会计科目
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
/// **************************************************************************
private void Linkbutton3_Click(object sender, System.EventArgs e)
{
string[] DataTypes = {"string","string"};
string[] pk = {"Hidden1","Hidden2"};
ArrayList al=this.GetPk("CheckBox1",DataTypes,pk,this.DataGrid1);
int i;
object[] obj;
//打开数据库连接
SqlConnection SqlCn = new SqlConnection (com.unicafe.common.Configuration.GetDBConnectionString());
SqlCn.Open();
SqlCommand cmd = SqlCn.CreateCommand();
try
{
//开始事务
SqlTransaction SqlTrans = SqlCn.BeginTransaction();
cmd.Transaction = SqlTrans;
for(i=0;i<al.Count;i++)
{
obj =(object[])al[i];
this.CW_KJKM.KJND=obj[0].ToString();
this.CW_KJKM.KMBM=obj[1].ToString();
this.CW_KJKM = this.CW_KJKMMgr.GetCW_KJKM(this.CW_KJKM.KJND, this.CW_KJKM.KMBM);
this.CW_KJKM.TYBJ = "0";
//检查该会计科目是否允许启用
if(this.CW_KJKMMgr.CheckChild(cmd, this.CW_KJKM.KJND, this.CW_KJKM.KMBM, 2) == true)
{
if(this.CW_KJKMMgr.UpdateCW_KJKM(cmd, this.CW_KJKM) == false) //如果允许则调用修改方法修改启用标记
{
SqlTrans.Rollback();
SqlCn.Close();
Prompt.PromptError(this, "启用操作执行失败。");
return;
}
}
//检查不通过则给出提示并退出
else
{
SqlTrans.Rollback();
SqlCn.Close();
Prompt.PromptAlert(this, "有些会计科目的上级科目还处于停用状态。<br>要想启用某会计科目,请先启用该会计科目的上级科目。");
return;
}
}
SqlTrans.Commit();
SqlCn.Close();
CommonService.BindDataGrid(this, ViewState["sql"].ToString(), DataGrid1, "Data", true);
}
catch(Exception e1)
{
Prompt.PromptError(this,"在执行启用会计科目操作时产生异常。");
LogService.Write (e1.Message);
SqlCn.Close();
return;
}
}
private void DataGrid1_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
}
/// **************************************************************************
/// END
/// **************************************************************************
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -