protected void deletebt_Click(object sender, EventArgs e) { string sqltext; sqltext = "select * from EQU_tzsb order by Id"; setpagerparm("EQU_tzsb", "Id", "Id*1 as Id,Code,Name,Type,Specification,Ocode,Rcode,Ucode,Manufa,Position,Ustate,Redate,Remark", "", "Name LIKE'%" + name.Text.ToString().Trim() + "%'", 0, 10); DataTable dt = DBCallCommon.GetDTUsingSqlText(sqltext); string strId = ""; foreach (RepeaterItem e_id in tzsbRepeater.Items) { CheckBox chk = (CheckBox)e_id.FindControl("checkboxstaff"); if (chk.Checked) { strId += "'" + ((Label)e_id.FindControl("Id")).Text + "'" + ","; } } if (strId.Length > 1) { strId = strId.Substring(0, strId.Length - 1); sqlConn.ConnectionString = DBCallCommon.GetStringValue("connectionStrings"); System.Data.SqlClient.SqlCommand sqlCmd = new System.Data.SqlClient.SqlCommand("delete from EQU_tzsb where Id in (" + strId + ")", sqlConn); DBCallCommon.openConn(sqlConn); SqlDataReader dr = sqlCmd.ExecuteReader(CommandBehavior.CloseConnection); dr.Close(); } DBCallCommon.closeConn(sqlConn); databind(); }
protected void btn_antihs_Click(object sender, EventArgs e) { SqlConnection sqlConn = new SqlConnection(); sqlConn.ConnectionString = DBCallCommon.GetStringValue("connectionStrings"); DBCallCommon.openConn(sqlConn); SqlCommand sqlCmd = new SqlCommand("GouJiRuKuHeSuanAnti", sqlConn); sqlCmd.CommandType = CommandType.StoredProcedure; sqlCmd.CommandTimeout = 0; sqlCmd.Parameters.Add("@gmonth", SqlDbType.VarChar, 2); sqlCmd.Parameters["@gmonth"].Value = getMonth(); sqlCmd.Parameters.Add("@gyear", SqlDbType.VarChar, 4); sqlCmd.Parameters["@gyear"].Value = getYear(); sqlCmd.Parameters.Add("@retVal", SqlDbType.Int, 1).Direction = ParameterDirection.ReturnValue; //增加返回值参数@retVal sqlCmd.ExecuteNonQuery(); DBCallCommon.closeConn(sqlConn); if (Convert.ToInt32(sqlCmd.Parameters["@retVal"].Value) == 0) { string script = @"alert('反入库核算成功!');location.href ='FM_RuKu_Adjust_Accounts.aspx'"; ScriptManager.RegisterStartupScript(this, this.GetType(), "error", script, true); } else if (Convert.ToInt32(sqlCmd.Parameters["@retVal"].Value) == 1) { string script = @"alert('反入库核算失败!');'"; ScriptManager.RegisterStartupScript(this, this.GetType(), "error", script, true); } }
protected void deletebt_Click(object sender, EventArgs e) { string strId = ""; foreach (RepeaterItem e_id in equipmentRepeater.Items) { CheckBox chk = (CheckBox)e_id.FindControl("checkboxstaff"); if (chk.Checked) { strId += "'" + ((Label)e_id.FindControl("Id")).Text + "'" + ","; } } if (strId.Length > 1) { strId = strId.Substring(0, strId.Length - 1); sqlConn.ConnectionString = DBCallCommon.GetStringValue("connectionStrings"); System.Data.SqlClient.SqlCommand sqlCmd = new System.Data.SqlClient.SqlCommand("delete from ESM_EQU where Id in (" + strId + ")", sqlConn); DBCallCommon.openConn(sqlConn); SqlDataReader dr = sqlCmd.ExecuteReader(CommandBehavior.CloseConnection); dr.Close(); } DBCallCommon.closeConn(sqlConn); UCPaging1.CurrentPage = 1; ReGetBoundData(); }
protected void deletebt_Click(object sender, EventArgs e) { string strId = ""; DDlpartment.SelectedValue = "00"; DDlgroup.SelectedValue = "00"; foreach (RepeaterItem e_id in tbds_staffinfoRepeater.Items) { CheckBox chk = (CheckBox)e_id.FindControl("checkboxstaff"); if (chk.Checked) { strId += "'" + ((Label)e_id.FindControl("ST_CODE")).Text + "'" + ","; } } if (strId.Length > 1) { strId = strId.Substring(0, strId.Length - 1); sqlConn.ConnectionString = DBCallCommon.GetStringValue("connectionStrings"); System.Data.SqlClient.SqlCommand sqlCmd = new System.Data.SqlClient.SqlCommand("update TBDS_STAFFINFO set ST_PD=1 where ST_ID in (" + strId + ")", sqlConn); DBCallCommon.openConn(sqlConn); SqlDataReader dr = sqlCmd.ExecuteReader(CommandBehavior.CloseConnection); dr.Close(); } DBCallCommon.closeConn(sqlConn); databind(); }
protected void deletebt_Click(object sender, EventArgs e) { Dfinddept1.SelectedValue = "00"; Dfinddept2.SelectedValue = "00"; Radiogrouportw.Visible = false; //隐藏 Radiogrouportw.SelectedValue = "1"; //默认为岗位/班组 DataTable dt = null; SqlConnection sqlConn = new SqlConnection(); sqlConn.ConnectionString = DBCallCommon.GetStringValue("connectionStrings"); DBCallCommon.openConn(sqlConn); SqlCommand sqlCmd = new SqlCommand();//选择用 sqlCmd.Connection = sqlConn; SqlCommand sqlCmd1 = new SqlCommand();//删除用 sqlCmd1.Connection = sqlConn; string cannotstr; foreach (RepeaterItem e_id in tbds_depinfoRepeater.Items) { CheckBox chk = (CheckBox)e_id.FindControl("checkboxdep"); if (chk.Checked) { cannotstr = ((Label)e_id.FindControl("DEP_CODE")).Text; #region //查找对象 if (Radiogrouportw.SelectedValue == "0") { sqlCmd.CommandText = "select * from TBDS_STAFFINFO where ST_JOBCAT LIKE '" + cannotstr + "%'"; sqlCmd1.CommandText = "delete from TBDS_JOBCATINFO where JC_ID LIKE '" + cannotstr + "%'"; } else { sqlCmd.CommandText = "select * from TBDS_STAFFINFO where ST_DEPID LIKE '" + cannotstr + "%'"; sqlCmd1.CommandText = "delete from TBDS_DEPINFO where DEP_CODE LIKE '" + cannotstr + "%'"; } #endregion dt = DBCallCommon.GetDataTableUsingCmd(sqlCmd); if (dt.Rows.Count > 0) { Lnumber.Text = Convert.ToString(dt.Rows.Count); Response.Write("<script>alert('编码为" + cannotstr + "下有人员,不能删除,若想删除,请删除该编码下的所有人员!');</script>"); } else { sqlCmd1.ExecuteNonQuery();//执行删除操作 } } } UCPaging1.CurrentPage = 1; databind(); DBCallCommon.closeConn(sqlConn); }
/*****************************反核算***************************/ protected void btn_Antihs_Click(object sender, EventArgs e) { SqlConnection sqlConn = new SqlConnection(); sqlConn.ConnectionString = DBCallCommon.GetStringValue("connectionStrings"); DBCallCommon.openConn(sqlConn); SqlCommand sqlCmd = new SqlCommand("AntiAccounting", sqlConn); sqlCmd.CommandType = CommandType.StoredProcedure; sqlCmd.Parameters.Add("@gmonth", SqlDbType.VarChar, 2); sqlCmd.Parameters["@gmonth"].Value = getMonth(); sqlCmd.Parameters.Add("@gyear", SqlDbType.VarChar, 4); sqlCmd.Parameters["@gyear"].Value = getYear(); sqlCmd.Parameters.Add("@retVal", SqlDbType.Int, 1).Direction = ParameterDirection.ReturnValue; //增加返回值参数@retVal sqlCmd.ExecuteNonQuery(); DBCallCommon.closeConn(sqlConn); if (Convert.ToInt32(sqlCmd.Parameters["@retVal"].Value) == 0) { //反核算成功 string script = @"alert('反核算成功!');"; ScriptManager.RegisterStartupScript(this, this.GetType(), "error", script, true); btn_hs.Enabled = true; btn_antihs.Enabled = false; bindGrid(); } else if (Convert.ToInt32(sqlCmd.Parameters["@retVal"].Value) == 1) { //关账失败! string script = @"alert('系统未核算,不能反核算!');"; //this.Page.ClientScript.RegisterStartupScript(this.GetType(), "error", script, true); ScriptManager.RegisterStartupScript(this, this.GetType(), "error", script, true); } else if (Convert.ToInt32(sqlCmd.Parameters["@retVal"].Value) == 2) { //关账失败! string script = @"alert('系统反核算失败!');"; //this.Page.ClientScript.RegisterStartupScript(this.GetType(), "error", script, true); ScriptManager.RegisterStartupScript(this, this.GetType(), "error", script, true); } }
//private void getZanGuBuCha() //获取暂估差金额,,入库单金额=发票金额-暂估差 //{ // //核算后获取发票金额 // //暂估差额 // string strperiod = ddl_year.SelectedValue + "-" + ddl_month.SelectedValue; // string condition = "CONVERT(varchar(100),(DIFYEAR+'-'+DIFMONTH), 23) between '" + strperiod + "' and '" + strperiod + "'AND round(DIFAMTMNY,2)!=0"; // string sql = "select CAST(round(isnull(sum(DIFAMTMNY),0),2) AS FLOAT) as TotalAmount from View_FM_INHSDETAILDIFMAR where " + condition; // SqlDataReader sdr = DBCallCommon.GetDRUsingSqlText(sql); // if (sdr.Read()) // { // hfdZanGuChaAmount.Value = sdr["TotalAmount"].ToString(); // } // sdr.Close(); //} /*****************************入库核算***************************/ protected void btn_hs_Click(object sender, EventArgs e) { string sqlifrksh = "select * from View_SM_IN where WG_STATE<>'2'"; DataTable dtifrksh = DBCallCommon.GetDTUsingSqlText(sqlifrksh); if (dtifrksh.Rows.Count > 0) { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", "alert('存在未审核的入库单!')", true); return; } SqlConnection sqlConn = new SqlConnection(); sqlConn.ConnectionString = DBCallCommon.GetStringValue("connectionStrings"); DBCallCommon.openConn(sqlConn); SqlCommand sqlCmd = new SqlCommand("GouJiRuKuHeSuan", sqlConn); sqlCmd.CommandType = CommandType.StoredProcedure; sqlCmd.CommandTimeout = 0; sqlCmd.Parameters.Add("@gmonth", SqlDbType.VarChar, 2); sqlCmd.Parameters["@gmonth"].Value = getMonth(); sqlCmd.Parameters.Add("@gyear", SqlDbType.VarChar, 4); sqlCmd.Parameters["@gyear"].Value = getYear(); sqlCmd.Parameters.Add("@retVal", SqlDbType.Int, 1).Direction = ParameterDirection.ReturnValue; //增加返回值参数@retVal sqlCmd.ExecuteNonQuery(); DBCallCommon.closeConn(sqlConn); if (Convert.ToInt32(sqlCmd.Parameters["@retVal"].Value) == 0) { string script = @"alert('入库核算成功!');location.href ='FM_RuKu_Adjust_Accounts.aspx'"; ScriptManager.RegisterStartupScript(this, this.GetType(), "error", script, true); } else if (Convert.ToInt32(sqlCmd.Parameters["@retVal"].Value) == 1) { string script = @"alert('入库核算失败!');'"; ScriptManager.RegisterStartupScript(this, this.GetType(), "error", script, true); } }
protected void btnSave_Replace(object sender, EventArgs e) { string sqltext; if (((Button)sender).CommandName == "Replace") { sqltext = "update " + tablename + " set " + ddlRepType.SelectedValue + "=REPLACE(" + ddlRepType.SelectedValue + ",'" + txtStart.Text.Trim() + "','" + txtEnd.Text.Trim() + "') WHERE " + ViewState["Org"].ToString() + ""; string conStr = DBCallCommon.GetStringValue("connectionStrings"); SqlConnection conn = new SqlConnection(conStr); SqlCommand sc = new SqlCommand(); sc.CommandType = CommandType.Text; sc.Connection = conn; sc.CommandText = sqltext; DBCallCommon.openConn(conn); int rowEffected = sc.ExecuteNonQuery(); DBCallCommon.closeConn(conn); ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", "alert('替换成功!!!\\r\\r影响行数【" + rowEffected + "】');", true); } else if (((Button)sender).CommandName == "Add") { sqltext = "update " + tablename + " set " + ddlRepType.SelectedValue + "=" + ddlRepType.SelectedValue + "+' " + txtAdd.Text.Trim() + "' WHERE " + ViewState["Org"].ToString() + ""; string conStr = DBCallCommon.GetStringValue("connectionStrings"); SqlConnection conn = new SqlConnection(conStr); SqlCommand sc = new SqlCommand(); sc.CommandType = CommandType.Text; sc.Connection = conn; sc.CommandText = sqltext; DBCallCommon.openConn(conn); int rowEffected = sc.ExecuteNonQuery(); DBCallCommon.closeConn(conn); ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", "alert('追加成功!!!\\r\\r影响行数【" + rowEffected + "】');", true); } }
/*****************************月末出库核算***************************/ protected void btn_hs_Click(object sender, EventArgs e) { string sqlifcksh = "select * from View_SM_OUT where TotalState<>'2'"; DataTable dtifcksh = DBCallCommon.GetDTUsingSqlText(sqlifcksh); if (dtifcksh.Rows.Count > 0) { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", "alert('存在未审核的出库单!')", true); return; } SqlConnection sqlConn = new SqlConnection(); sqlConn.ConnectionString = DBCallCommon.GetStringValue("connectionStrings"); DBCallCommon.openConn(sqlConn); SqlCommand sqlCmd = new SqlCommand("YueMoChuKuHeSuan", sqlConn); sqlCmd.CommandType = CommandType.StoredProcedure; sqlCmd.CommandTimeout = 0; sqlCmd.Parameters.Add("@gmonth", SqlDbType.VarChar, 2); sqlCmd.Parameters["@gmonth"].Value = getMonth(); sqlCmd.Parameters.Add("@gyear", SqlDbType.VarChar, 4); sqlCmd.Parameters["@gyear"].Value = getYear(); sqlCmd.Parameters.Add("@retVal", SqlDbType.Int, 1).Direction = ParameterDirection.ReturnValue; //增加返回值参数@retVal sqlCmd.ExecuteNonQuery(); DBCallCommon.closeConn(sqlConn); if (Convert.ToInt32(sqlCmd.Parameters["@retVal"].Value) == 0) { string script = @"alert('出库核算成功!');location.href ='FM_YueMo_ChuKu_Adjust_Accounts.aspx'"; ScriptManager.RegisterStartupScript(this, this.GetType(), "error", script, true); } else if (Convert.ToInt32(sqlCmd.Parameters["@retVal"].Value) == 1) { //关账失败! string script = @"alert('系统已核算!');"; ScriptManager.RegisterStartupScript(this, this.GetType(), "error", script, true); } else if (Convert.ToInt32(sqlCmd.Parameters["@retVal"].Value) == 2) { //出现了未审核的入库单 //ScriptManager.RegisterStartupScript(this, this.GetType(), "error", "ShowViewModal('2');", true); Response.Redirect("FM_YueMo_ChuKu_Adjust_Accounts_Error.aspx?errorID=2"); } else if (Convert.ToInt32(sqlCmd.Parameters["@retVal"].Value) == 3) { //出现了未审核的出库单 //ScriptManager.RegisterStartupScript(this, this.GetType(), "error", "ShowViewModal('3');", true); Response.Redirect("FM_YueMo_ChuKu_Adjust_Accounts_Error.aspx?errorID=3"); } else if (Convert.ToInt32(sqlCmd.Parameters["@retVal"].Value) == 4) { //在核算期间,系统出现了新的入库单 //ScriptManager.RegisterStartupScript(this, this.GetType(), "error", "ShowViewModal('4');", true); Response.Redirect("FM_YueMo_ChuKu_Adjust_Accounts_Error.aspx?errorID=4"); } else if (Convert.ToInt32(sqlCmd.Parameters["@retVal"].Value) == 5) { //在核算期间,系统出现了新的出库单 //ScriptManager.RegisterStartupScript(this, this.GetType(), "error", "ShowViewModal('5');", true); Response.Redirect("FM_YueMo_ChuKu_Adjust_Accounts_Error.aspx?errorID=5"); } else if (Convert.ToInt32(sqlCmd.Parameters["@retVal"].Value) == 6) { string script = @"alert('系统在统计库存数据时,发生了单据错误!');"; ScriptManager.RegisterStartupScript(this, this.GetType(), "error", script, true); } }