protected void GridView4_RowCommand(object sender, GridViewCommandEventArgs e) { int rowIndex = int.Parse(e.CommandArgument.ToString()); String cmd = e.CommandName; GridViewRow gvr = GridView4.Rows[rowIndex]; int id = int.Parse(gvr.Cells[1].Text); if (cmd == "Allocate") { DropDownList allocation = gvr.FindControl("cmbAccount") as DropDownList; int allVal = int.Parse(allocation.SelectedValue); if (allVal != 0) { DateTime trnDate = DateTime.Parse(gvr.Cells[2].Text); String description = gvr.Cells[3].Text; double drVal = double.Parse(gvr.Cells[4].Text); double crVal = double.Parse(gvr.Cells[5].Text); double val = (drVal != 0 ? drVal * -1 : crVal); String[] accs = getAccounts(allVal); if (accs != null) { String sql = "INSERT INTO tblRentalRecon(rentalId, trnDate, value, account, contra) VALUES(" + id.ToString(); sql += " , '" + trnDate.ToString() + "', " + val.ToString() + ", '" + accs[0] + "', '" + accs[1] + "')"; utils.executeQuery(sql, null); SqlDataSource4.DataBind(); GridView4.DataBind(); } } } else if (cmd == "Delete") { } }
protected void ddlDept_SelectedIndexChanged(object sender, EventArgs e) { var mgCookie = new ManageCookie(); users ck = mgCookie.ReadCookies(); if (ck != null) { var strSql = new StringBuilder(); strSql.Append("select pj_id, pj_code, d_id, pj_name, pj_year, pj_budget, pj_complete_status, pj_category, "); strSql.Append(" pj_approval_status, pj_lastupdate from projects "); strSql.Append(" where pj_status = 'real' and pj_complete_status = N'ไม่อยู่ในเกณฑ์การประเมิน/กรอกสมบูรณ์' and "); strSql.Append(" d_id = " + ddlDept.SelectedValue); SqlDataSource4.SelectCommand = strSql.ToString(); SqlDataSource4.DataBind(); GridView1.DataSource = SqlDataSource4; GridView1.DataBind(); var dtView = (DataView)SqlDataSource4.Select(new DataSourceSelectArguments()); var listt = (from t in dtView.Table.AsEnumerable() group t by t.Field <string>("pj_year") into g orderby g.Key select new { pj_year = g.Key, }); ddlProjectYear.DataSource = listt; ddlProjectYear.DataBind(); ddlProjectYear.Items.Insert(0, new ListItem("[ทุกปีงบประมาณ]", String.Empty)); ddlProjectYear.SelectedIndex = 0; } }
protected void ddlMin_SelectedIndexChanged(object sender, EventArgs e) { if (ddlMin.SelectedIndex != 0) { StringBuilder strSQL = new StringBuilder(); strSQL.Append("select m.mi_code, m.mi_name, d.d_name, d_code, d.d_id as d_id, d.id, m.mi_id from department d, ministry m "); strSQL.Append("where d.mi_id = m.mi_id and d.mi_id = " + ddlMin.SelectedValue); SqlDataSource4.SelectCommand = strSQL.ToString(); SqlDataSource4.DataBind(); GridView1.DataSource = SqlDataSource4; GridView1.DataBind(); } else { StringBuilder strSQL = new StringBuilder(); strSQL.Append("select m.mi_code, m.mi_name, d.d_name, d_code, d.d_id as d_id, d.id, m.mi_id from department d, ministry m "); strSQL.Append("where d.mi_id = m.mi_id and d.mi_id = 0"); SqlDataSource4.SelectCommand = strSQL.ToString(); SqlDataSource4.DataBind(); GridView1.DataSource = SqlDataSource4; GridView1.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { ManageCookie mgCookie = new ManageCookie(); users ck = mgCookie.ReadCookies(); if (ck != null) { String strPJid = ck.pj_id; string strPjType = string.Empty; StringBuilder strSQL = new StringBuilder(); strSQL.Append("select d.d_code, d.d_name, m.mi_code, m.mi_name, p.pj_code, p.d_id, p.pj_name, y.yut_name, p.pj_year, p.pj_budget, pj_integrateProject, pj_relateDept, pj_background, pj_urgency, pj_type"); strSQL.Append(" from projects p, department d, ministry m, yutasad y"); strSQL.Append(" where p.d_id = d.d_id and p.mi_id = m.mi_id and p.pj_yut_id = y.yut_id and p.pj_id = '" + strPJid + "'"); SqlDataSource4.SelectCommand = strSQL.ToString(); SqlDataSource4.DataBind(); DataView dv1 = (DataView)SqlDataSource4.Select(DataSourceSelectArguments.Empty); foreach (DataRow dRow in dv1.Table.Rows) { lblDeptCode.Text = dRow["mi_code"].ToString(); lblDeptName.Text = dRow["mi_name"].ToString(); lblDivisionCode.Text = dRow["d_code"].ToString(); lblDivisionName.Text = dRow["d_name"].ToString(); lblProjectName.Text = dRow["pj_name"].ToString(); lblProjectCode.Text = dRow["pj_code"].ToString(); lblYutasard.Text = dRow["yut_name"].ToString(); //lblIntegrateProject.Text = dRow["pj_integrateProject"].ToString(); //lblRelateDept.Text = dRow["pj_relateDept"].ToString(); lblBudget.Text = dRow["pj_budget"].ToString(); lblYear.Text = dRow["pj_year"].ToString(); strPjType = dRow["pj_type"].ToString(); } if (strPjType.Trim() == "โครงการใหม่") { linkQuestionE.Visible = false; } else if (strPjType.Trim() == "โครงการต่อเนื่องหรือโครงการขยายผล") { linkQuestionE.Visible = true; } else { Response.Redirect("default.aspx"); } } else { //redirect to login page Response.Redirect("default.aspx"); } } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { ManageCookie mgCookie = new ManageCookie(); users ck = mgCookie.ReadCookies(); if (ck != null) { String strPJid = ck.pj_id; //String strPJCode = "01001-100"; StringBuilder strSQL = new StringBuilder(); strSQL.Append("select d.d_code, d.d_name, m.mi_code, m.mi_name, p.pj_code, p.d_id, p.pj_name, y.yut_name, p.pj_year, p.pj_budget, pj_integrateProject, pj_relateDept, pj_background, pj_urgency, pj_category"); strSQL.Append(" from projects p, department d, ministry m, yutasad y"); strSQL.Append(" where p.d_id = d.d_id and p.mi_id = m.mi_id and p.pj_yut_id = y.yut_id and p.pj_id = " + strPJid); SqlDataSource4.SelectCommand = strSQL.ToString(); SqlDataSource4.DataBind(); DataView dv1 = (DataView)SqlDataSource4.Select(DataSourceSelectArguments.Empty); foreach (DataRow dRow in dv1.Table.Rows) { lblDeptCode.Text = dRow["mi_code"].ToString(); lblDeptName.Text = dRow["mi_name"].ToString(); lblDivisionCode.Text = dRow["d_code"].ToString(); lblDivisionName.Text = dRow["d_name"].ToString(); lblProjectName.Text = dRow["pj_name"].ToString(); lblProjectCode.Text = dRow["pj_code"].ToString(); lblYutasard.Text = dRow["yut_name"].ToString(); lblIntegrateProject.Text = dRow["pj_integrateProject"].ToString(); lblRelateDept.Text = dRow["pj_relateDept"].ToString(); lblBudget.Text = dRow["pj_budget"].ToString(); lblYear.Text = dRow["pj_year"].ToString(); if (dRow["pj_category"].ToString() != string.Empty) { if (dRow["pj_category"].ToString() == "บริหารทั่วไป") { radProjectCate.SelectedIndex = 0; } else if (dRow["pj_category"].ToString() == "บริหารสังคม") { radProjectCate.SelectedIndex = 1; } else if (dRow["pj_category"].ToString() == "เศรษฐกิจ") { radProjectCate.SelectedIndex = 2; } } } } else { //redirect to login page } } }
protected void Page_Load(object sender, EventArgs e) { ManageCookie mgCookie = new ManageCookie(); users ck = mgCookie.ReadCookies(); if (ck != null) { string strDeptID = ck.d_code; //Redirect Login users to pending page //redirectToPendingPage(); //string strDeptID = "01001"; string strProjectStatus = ck.pj_status; //keep project code in cookie for usage in follwing pages mgCookie.UpdateCookies("pj_status", strProjectStatus); string strSQL1 = "select * from dbo.department d, dbo.ministry m where d.mi_id = m.mi_id and d.d_code = '" + strDeptID + "'"; SqlDataSource4.SelectCommand = strSQL1; SqlDataSource4.DataBind(); DataView dv1 = (DataView)SqlDataSource4.Select(DataSourceSelectArguments.Empty); foreach (DataRow dRow in dv1.Table.Rows) { lblDeptCode.Text = dRow["mi_code"].ToString(); lblDeptName.Text = dRow["mi_name"].ToString(); lblDivisionCode.Text = dRow["d_code"].ToString(); lblDivisionName.Text = dRow["d_name"].ToString(); mgCookie.UpdateCookies("mi_id", dRow["mi_id"].ToString()); } if (!Page.IsPostBack) { string strSQL = "SELECT * from dbo.projects where pj_id = " + ck.pj_id; SqlDataSource2.SelectCommand = strSQL; SqlDataSource2.DataBind(); DataView dv = (DataView)SqlDataSource2.Select(DataSourceSelectArguments.Empty); lblProjectCode.Text = dv.Table.Rows[0]["pj_code"].ToString(); txtProjectName.Text = dv.Table.Rows[0]["pj_name"].ToString(); ddlYudtasad.SelectedValue = dv.Table.Rows[0]["pj_yut_id"].ToString(); ddlYear.SelectedValue = dv.Table.Rows[0]["pj_year"].ToString(); txtBudget.Text = dv.Table.Rows[0]["pj_budget"].ToString(); DropDownList2.SelectedValue = dv.Table.Rows[0]["pj_budget_type"].ToString(); //txtIntegrate.Text = dv.Table.Rows[0]["pj_integrateproject"].ToString(); //txtRelate.Text = dv.Table.Rows[0]["pj_relateDept"].ToString(); } } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { ManageCookie mgCookie = new ManageCookie(); users ck = mgCookie.ReadCookies(); if (ck != null) { string strPJCode = ck.pj_code; string strPJStatus = ck.pj_status; string strPJ_ID = ck.pj_id; StringBuilder strSQL = new StringBuilder(); strSQL.Append("select d.d_code, d.d_name, m.mi_code, m.mi_name, p.pj_code, p.d_id, p.pj_name, y.yut_name, p.pj_year, p.pj_budget, pj_integrateProject, pj_relateDept, pj_filter_q1, pj_filter_q2, pj_filter_q3, pj_filter_q4 "); strSQL.Append(" from projects p, department d, ministry m, yutasad y"); strSQL.Append(" where p.d_id = d.d_id and p.mi_id = m.mi_id and p.pj_yut_id = y.yut_id and p.pj_id = " + strPJ_ID); SqlDataSource4.SelectCommand = strSQL.ToString(); SqlDataSource4.DataBind(); DataView dv1 = (DataView)SqlDataSource4.Select(DataSourceSelectArguments.Empty); if (dv1.Table.Rows.Count > 0) { foreach (DataRow dRow in dv1.Table.Rows) { lblDeptCode.Text = dRow["mi_code"].ToString(); lblDeptName.Text = dRow["mi_name"].ToString(); lblDivisionCode.Text = dRow["d_code"].ToString(); lblDivisionName.Text = dRow["d_name"].ToString(); lblProjectName.Text = dRow["pj_name"].ToString(); lblProjectCode.Text = dRow["pj_code"].ToString(); lblYutasard.Text = dRow["yut_name"].ToString(); lblIntegrateProject.Text = dRow["pj_integrateProject"].ToString(); lblRelateDept.Text = dRow["pj_relateDept"].ToString(); lblBudget.Text = dRow["pj_budget"].ToString(); lblYear.Text = dRow["pj_year"].ToString(); radQ1.SelectedValue = dRow["pj_filter_q1"].ToString(); radQ2.SelectedValue = dRow["pj_filter_q2"].ToString(); } } else { //cannot display project details, redirect to login page } } else { //cannot find user login cookie, redirect to login page } } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { ManageCookie mgCookie = new ManageCookie(); users ck = mgCookie.ReadCookies(); if (ck != null) { String strPJid = ck.pj_id; StringBuilder strSQL = new StringBuilder(); strSQL.Append("select d.d_code, d.d_name, m.mi_code, m.mi_name, p.pj_code, p.d_id, p.pj_name, y.yut_name, p.pj_year, p.pj_budget, pj_integrateProject, pj_relateDept, pj_background, pj_urgency, pj_type, pj_complete_status "); strSQL.Append(" from projects p, department d, ministry m, yutasad y"); strSQL.Append(" where p.d_id = d.d_id and p.mi_id = m.mi_id and p.pj_yut_id = y.yut_id and p.pj_id = '" + strPJid + "'"); SqlDataSource4.SelectCommand = strSQL.ToString(); SqlDataSource4.DataBind(); DataView dv1 = (DataView)SqlDataSource4.Select(DataSourceSelectArguments.Empty); foreach (DataRow dRow in dv1.Table.Rows) { lblDeptCode.Text = dRow["mi_code"].ToString(); lblDeptName.Text = dRow["mi_name"].ToString(); lblDivisionCode.Text = dRow["d_code"].ToString(); lblDivisionName.Text = dRow["d_name"].ToString(); lblProjectName.Text = dRow["pj_name"].ToString(); lblProjectCode.Text = dRow["pj_code"].ToString(); lblYutasard.Text = dRow["yut_name"].ToString(); //lblIntegrateProject.Text = dRow["pj_integrateProject"].ToString(); //lblRelateDept.Text = dRow["pj_relateDept"].ToString(); lblBudget.Text = dRow["pj_budget"].ToString(); lblYear.Text = dRow["pj_year"].ToString(); } gUtilities gt = new gUtilities(); litRisk1.Text = gt.getReportTammaTotal(ck.pj_id); litRisk2.Text = gt.getReportFactorRiskTotal(ck.pj_id); // litRisk12.Text = gt.getReportTammaMainTotal(ck.pj_id); // litRisk13.Text = gt.getReportTammaSubTotal(ck.pj_id); if (dv1.Table.Rows[0]["pj_complete_status"].ToString() == null) { Response.Redirect("project_summary.aspx"); } } else { //redirect Response.Redirect("project_summary.aspx"); } } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { ManageCookie mgCookie = new ManageCookie(); users ck = mgCookie.ReadCookies(); if (ck != null) { String strPJid = ck.pj_id; StringBuilder strSQL = new StringBuilder(); strSQL.Append("select d.d_code, d.d_name, m.mi_code, m.mi_name, p.pj_code, p.d_id, p.pj_name, y.yut_name, p.pj_year, p.pj_budget, pj_integrateProject, pj_relateDept, pj_background, pj_urgency,pj_risk_info, pj_risk_reduction1, pj_risk_reduction2, pj_risk_eval1, pj_risk_eval2, pj_risk_eval3"); strSQL.Append(" from projects p, department d, ministry m, yutasad y"); strSQL.Append(" where p.d_id = d.d_id and p.mi_id = m.mi_id and p.pj_yut_id = y.yut_id and p.pj_id = '" + strPJid + "'"); SqlDataSource4.SelectCommand = strSQL.ToString(); SqlDataSource4.DataBind(); DataView dv1 = (DataView)SqlDataSource4.Select(DataSourceSelectArguments.Empty); foreach (DataRow dRow in dv1.Table.Rows) { lblDeptCode.Text = dRow["mi_code"].ToString(); lblDeptName.Text = dRow["mi_name"].ToString(); lblDivisionCode.Text = dRow["d_code"].ToString(); lblDivisionName.Text = dRow["d_name"].ToString(); lblProjectName.Text = dRow["pj_name"].ToString(); lblProjectCode.Text = dRow["pj_code"].ToString(); lblYutasard.Text = dRow["yut_name"].ToString(); //lblIntegrateProject.Text = dRow["pj_integrateProject"].ToString(); //lblRelateDept.Text = dRow["pj_relateDept"].ToString(); lblBudget.Text = dRow["pj_budget"].ToString(); lblYear.Text = dRow["pj_year"].ToString(); txtBackground.Text = dRow["pj_background"].ToString(); txtUrgency.Text = dRow["pj_urgency"].ToString(); //txtRiskInfo.Text = dRow["pj_risk_info"].ToString(); //txtRiskReduction1.Text = dRow["pj_risk_reduction1"].ToString(); //txtRiskReduction2.Text = dRow["pj_risk_reduction2"].ToString(); //txtRiskEval1.Text = dRow["pj_risk_eval1"].ToString(); //txtRiskEval2.Text = dRow["pj_risk_eval2"].ToString(); //txtRiskEval3.Text = dRow["pj_risk_eval3"].ToString(); } } else { //redirect to login page } } }
protected void Button9_Click(object sender, EventArgs e) { try { if (TextBox20.Text != string.Empty) { int ID_Rubro, ID_Rubro2; // ID_Rubro = datos.ID_Rubro(TextBox20.Text); // ID_Rubro2 = datos.ID_Rubro2(TextBox20.Text); if (CheckBox2.Checked == false) { SqlDataSource4.SelectCommand = "SELECT DISTINCT Producto.ID_Producto,stuff((Select ', ' + OEM.OEM From OEM inner join Marca on OEM.ID_Marca = Marca.ID_Marca Where OEM.ID_Producto = Producto.ID_Producto For XML Path('')), 1,2,'') AS LISTAOEM , stuff((Select ', ' + CodigoProducto.Codigo From CodigoProducto inner join MarcaProd on CodigoProducto.ID_MaraProd = MarcaProd.ID_MaraProd Where CodigoProducto.ID_Producto = Producto.ID_Producto For XML Path('')), 1,2,'') AS LISTACODP,Producto.Descripcion, stuff((Select '| ' + AnioInicio + '-'+AnioFinal + ' ~ ' + Rubro +', '+ Modelo + ', ' + Marca From Marca inner join Modelo on Marca.ID_Marca = Modelo.ID_Marca inner join Rubro on Modelo.ID_Modelo = Rubro.ID_Modelo inner join AnioProducto on Rubro.ID_Rubro = AnioProducto.ID_Rubro Where AnioProducto.ID_Producto = Producto.ID_Producto For XML Path('')), 1,2,'') AS LISTANIOP,SubCategoria.SubCategoria+', '+ Categoria.Categoria AS Categoria, CAST(MarcaProd.ID_MaraProd AS VARCHAR) + ', '+ MarcaProd.MarcaP AS MarcaP, Stock.PrecioVenta, Stock.Cantidad, Stock.PrecioUnitario, Stock.Ubicacion, Medida.Medida, Tienda.Tienda, Stock.ID_Existencia FROM Medida INNER JOIN Stock INNER JOIN Tienda ON Stock.ID_Tienda = Tienda.ID_Tienda INNER JOIN Producto ON Stock.ID_Producto = Producto.ID_Producto INNER JOIN SubCategoria ON Producto.ID_SubCategoria = SubCategoria.ID_SubCategoria ON Medida.ID_Medida = Stock.ID_Medida INNER JOIN MarcaProd ON Stock.ID_MaraProd = MarcaProd.ID_MaraProd INNER JOIN Categoria ON SubCategoria.ID_Categoria = Categoria.ID_Categoria inner join OEM on Producto.ID_Producto = OEM.ID_Producto inner join CodigoProducto on Producto.ID_Producto = CodigoProducto.ID_Producto inner join AnioProducto on Producto.ID_Producto = AnioProducto.ID_Producto Where (Producto.Estado = 1) AND Tienda.ID_Tienda = " + Session["IDtienda"] + " AND (OEM.OEM like '%" + TextBox20.Text.Trim() + "%' OR CodigoProducto.Codigo like '%" + TextBox20.Text.Trim() + "%' OR Producto.Producto like '%" + TextBox20.Text.Trim() + "%')"; SqlDataSource4.DataBind(); } //else if (CheckBox2.Checked == false && CheckBox3.Checked == true && CheckBox4.Checked == false) //{ // SqlDataSource2.SelectCommand = "SELECT Producto.Codigo, Producto.Codigo2, Producto.Descripcion AS Producto, MarcaProd.MarcaP, Rubro.Rubro, Modelo.Modelo, Marca.Marca, Anio.Anio, Stock.Cantidad, Stock.Ubicacion, Stock.PrecioUnitario, Stock.PrecioVenta, Stock.ID_Existencia, Medida.Medida, Tienda.Tienda FROM Anio INNER JOIN Stock INNER JOIN Producto ON Stock.Codigo = Producto.Codigo ON Anio.ID_Anio = Stock.ID_Anio INNER JOIN Rubro ON Producto.ID_Rubro = Rubro.ID_Rubro INNER JOIN Marca INNER JOIN Modelo ON Marca.ID_Marca = Modelo.ID_Marca ON Rubro.ID_Modelo = Modelo.ID_Modelo INNER JOIN MarcaProd ON Producto.ID_MaraProd = MarcaProd.ID_MaraProd INNER JOIN Medida on Stock.ID_Medida = Medida.ID_Medida INNER JOIN Tienda ON Stock.ID_Tienda = Tienda.ID_Tienda WHERE Producto.Estado = 1 AND (Producto.Codigo like '%" + TextBox20.Text.Trim() + "%' OR Producto.Producto like '%" + TextBox20.Text.Trim() + "%' OR Producto.Codigo2 like '%" + TextBox20.Text.Trim() + "%') AND Marca.ID_Marca =" + DropDownList2.SelectedValue;// AND Rubro.ID_Rubro = " + ID_Rubro;//agregado 11/07 // SqlDataSource2.DataBind(); //} //else if (CheckBox2.Checked == false && CheckBox3.Checked == false && CheckBox4.Checked == true) //{ // SqlDataSource2.SelectCommand = "SELECT Producto.Codigo, Producto.Codigo2, Producto.Descripcion AS Producto, MarcaProd.MarcaP, Rubro.Rubro, Modelo.Modelo, Marca.Marca, Anio.Anio, Stock.Cantidad, Stock.Ubicacion, Stock.PrecioUnitario, Stock.PrecioVenta, Stock.ID_Existencia, Medida.Medida, Tienda.Tienda FROM Anio INNER JOIN Stock INNER JOIN Producto ON Stock.Codigo = Producto.Codigo ON Anio.ID_Anio = Stock.ID_Anio INNER JOIN Rubro ON Producto.ID_Rubro = Rubro.ID_Rubro INNER JOIN Marca INNER JOIN Modelo ON Marca.ID_Marca = Modelo.ID_Marca ON Rubro.ID_Modelo = Modelo.ID_Modelo INNER JOIN MarcaProd ON Producto.ID_MaraProd = MarcaProd.ID_MaraProd INNER JOIN Medida on Stock.ID_Medida = Medida.ID_Medida INNER JOIN Tienda ON Stock.ID_Tienda = Tienda.ID_Tienda WHERE Producto.Estado = 1 AND (Producto.Codigo like '%" + TextBox20.Text.Trim() + "%' OR Producto.Producto like '%" + TextBox20.Text.Trim() + "%' OR Producto.Codigo2 like '%" + TextBox20.Text.Trim() + "%') AND Modelo.ID_Modelo =" + DropDownList5.SelectedValue;// AND Rubro.ID_Rubro = " + ID_Rubro;//agregado 11/07 // SqlDataSource2.DataBind(); //} else if (CheckBox2.Checked == true) { SqlDataSource4.SelectCommand = "SELECT DISTINCT Producto.ID_Producto,stuff((Select ', ' + OEM.OEM From OEM inner join Marca on OEM.ID_Marca = Marca.ID_Marca Where OEM.ID_Producto = Producto.ID_Producto For XML Path('')), 1,2,'') AS LISTAOEM , stuff((Select ', ' + CodigoProducto.Codigo From CodigoProducto inner join MarcaProd on CodigoProducto.ID_MaraProd = MarcaProd.ID_MaraProd Where CodigoProducto.ID_Producto = Producto.ID_Producto For XML Path('')), 1,2,'') AS LISTACODP,Producto.Descripcion, stuff((Select '| ' + AnioInicio + '-'+AnioFinal + ' ~ ' + Rubro +', '+ Modelo + ', ' + Marca From Marca inner join Modelo on Marca.ID_Marca = Modelo.ID_Marca inner join Rubro on Modelo.ID_Modelo = Rubro.ID_Modelo inner join AnioProducto on Rubro.ID_Rubro = AnioProducto.ID_Rubro Where AnioProducto.ID_Producto = Producto.ID_Producto For XML Path('')), 1,2,'') AS LISTANIOP,SubCategoria.SubCategoria+', '+ Categoria.Categoria AS Categoria, CAST(MarcaProd.ID_MaraProd AS VARCHAR) + ', '+ MarcaProd.MarcaP AS MarcaP, Stock.PrecioVenta, Stock.Cantidad, Stock.PrecioUnitario, Stock.Ubicacion, Medida.Medida, Tienda.Tienda, Stock.ID_Existencia FROM Medida INNER JOIN Stock INNER JOIN Tienda ON Stock.ID_Tienda = Tienda.ID_Tienda INNER JOIN Producto ON Stock.ID_Producto = Producto.ID_Producto INNER JOIN SubCategoria ON Producto.ID_SubCategoria = SubCategoria.ID_SubCategoria ON Medida.ID_Medida = Stock.ID_Medida INNER JOIN MarcaProd ON Stock.ID_MaraProd = MarcaProd.ID_MaraProd INNER JOIN Categoria ON SubCategoria.ID_Categoria = Categoria.ID_Categoria inner join OEM on Producto.ID_Producto = OEM.ID_Producto inner join CodigoProducto on Producto.ID_Producto = CodigoProducto.ID_Producto inner join AnioProducto on Producto.ID_Producto = AnioProducto.ID_Producto Where (Producto.Estado = 1) AND (Tienda.ID_Tienda = " + TextBox1.Text + ") AND (OEM.OEM like '%" + TextBox20.Text.Trim() + "%' OR CodigoProducto.Codigo like '%" + TextBox20.Text.Trim() + "%' OR Producto.Producto like '%" + TextBox20.Text.Trim() + "%') AND (" + DropDownList7.SelectedItem + " BETWEEN AnioProducto.AnioInicio AND AnioProducto.AnioFinal) AND AnioProducto.ID_Rubro =" + DropDownList6.SelectedValue; SqlDataSource4.DataBind(); } else { Response.Write("<script>alert('Error, revise los campos. Ej: Puede ser que tanto marca como linea estan marcadas, marque solo uno')</script>"); } } else { Response.Write("<script>alert('Error, ingrese un valor')</script>"); } } catch { Response.Write("<script>alert('Error, revise los campos')</script>"); } }
protected void ddlDept_SelectedIndexChanged(object sender, EventArgs e) { StringBuilder strSQL = new StringBuilder(); strSQL.Append("select pj_id, pj_code, d_id, pj_name, pj_budget, pj_complete_status, pj_category, "); strSQL.Append(" pj_approval_status, pj_lastupdate from projects "); strSQL.Append(" where pj_status = '" + radProjectType.SelectedValue + "' and "); strSQL.Append(" d_id = " + ddlDept.SelectedValue); //Response.Write(strSQL.ToString()); //Response.End(); SqlDataSource4.SelectCommand = strSQL.ToString(); SqlDataSource4.DataBind(); GridView1.DataSource = SqlDataSource4; GridView1.DataBind(); }
protected void btnCancel_Click(object sender, EventArgs e) { lblResult.Text = string.Empty; txtDCode.Text = string.Empty; txtDName.Text = string.Empty; ddlMin.SelectedIndex = 0; StringBuilder strSQL = new StringBuilder(); strSQL.Append("select m.mi_code, m.mi_name, d.d_name, d_code, d.d_id as d_id, d.id, m.mi_id from department d, ministry m "); strSQL.Append("where d.mi_id = m.mi_id and d.mi_id = 0"); SqlDataSource4.SelectCommand = strSQL.ToString(); SqlDataSource4.DataBind(); GridView1.DataSource = SqlDataSource4; GridView1.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { ddlMin.DataSource = SqlDataSource2; ddlMin.DataTextField = "mi_name"; ddlMin.DataValueField = "mi_id"; ddlMin.DataBind(); ddlMin.Items.Insert(0, new ListItem("[กรุณาเลือก]", "[กรุณาเลือก]")); ddlMin.SelectedIndex = 0; } else { if (ddlMin.SelectedIndex != 0) { StringBuilder strSQL = new StringBuilder(); strSQL.Append("select m.mi_code, m.mi_name, d.d_name, d_code, d.d_id as d_id, d.id, m.mi_id from department d, ministry m "); strSQL.Append("where d.mi_id = m.mi_id and d.mi_id = " + ddlMin.SelectedValue); SqlDataSource4.SelectCommand = strSQL.ToString(); SqlDataSource4.DataBind(); GridView1.DataSource = SqlDataSource4; GridView1.DataBind(); } else { StringBuilder strSQL = new StringBuilder(); strSQL.Append("select m.mi_code, m.mi_name, d.d_name, d_code, d.d_id as d_id, d.id, m.mi_id from department d, ministry m "); strSQL.Append("where d.mi_id = m.mi_id and d.mi_id = 0"); SqlDataSource4.SelectCommand = strSQL.ToString(); SqlDataSource4.DataBind(); GridView1.DataSource = SqlDataSource4; GridView1.DataBind(); } } }
protected void Page_Load(object sender, EventArgs e) { userManager theUserManager = (userManager)Session["theUserManager"]; theCompanyCode = theUserManager.getCompanyCode(); theProgramCode = "atpu1E00"; theUserId = theUserManager.getUserId(); theUserCode = theUserManager.getUserCode(); //string Sql2 = "SELECT STATION_CODE,STATION_NAME FROM CODE_STATION order by STATION_CODE "; //SqlDataSource2.SelectCommand = Sql2; //SqlDataSource2.DataBind(); string Sql4 = "select a.pline_code,b.rmes_id,b.pline_name from VW_USER_ROLE_PROGRAM a " + "left join code_product_line b on a.pline_code=b.pline_code " + "where a.COMPANY_CODE = '" + theCompanyCode + "' and a.user_id='" + theUserId + "' and a.program_code='" + theProgramCode + "' order by b.PLINE_NAME"; SqlDataSource4.SelectCommand = Sql4; SqlDataSource4.DataBind(); }
protected void DeleteRecordByID(int pj_id) { projects pj = new projects(); int ret = pj.insert_ProjectBackUp(pj_id.ToString()); if (ret > 0) { pj.delete_project(pj_id.ToString()); StringBuilder strSQL = new StringBuilder(); strSQL.Append("select pj_id, pj_code, d_id, pj_name, pj_budget, pj_complete_status, pj_category, "); strSQL.Append(" pj_approval_status, pj_lastupdate from projects "); strSQL.Append(" where pj_status = '" + radProjectType.SelectedValue + "' and "); strSQL.Append(" d_id = " + ddlDept.SelectedValue); SqlDataSource4.SelectCommand = strSQL.ToString(); SqlDataSource4.DataBind(); GridView1.DataSource = SqlDataSource4; GridView1.DataBind(); } }
protected void AddStudent(object sender, EventArgs e) { Page.ClientScript.RegisterStartupScript(GetType(), "id", "toggle_forms('StudentSection')", true); if (Page.IsValid) { Stream str = FileUpload1.PostedFile.InputStream; BinaryReader br = new BinaryReader(str); Byte[] size = br.ReadBytes((int)str.Length); DBHandler.DBHandler db = new DBHandler.DBHandler(con); Entities.personalInfo t1 = new Entities.personalInfo() { pKId = SID.Value, passCode = SPassword.Value, firstName = SFirstName.Value, middleName = SMiddleName.Value, lastName = SLastName.Value, phone = SPhoneNo.Value, cellNo = SMobNo.Value, emergencyContact = SEmergency.Value, iAm = Session["School"].ToString(), eMail = SEmail.Value, enrollmentDate = SEnrollmentDate.Text, dOB = SDateOfBirth.Text, gender = Convert.ToInt32(SGender.SelectedIndex.ToString()), userType = STypeOfUser.SelectedValue, isActive = SIsActive.Checked, isNew = IsNew.Checked, address1 = SAddress1.Value, address2 = SAddress2.Value, address3 = SAddress3.Value, fileName = Path.GetFileName(FileUpload1.PostedFile.FileName), recordFile = size, }; db.insertTest(t1); Label2.Text = "Added Successfully"; SqlDataSource4.DataBind(); GridView3.DataBind(); } }
protected void AdminAssign(object sender, EventArgs e) { Page.ClientScript.RegisterStartupScript(GetType(), "id", "toggle_forms('admin')", true); if (Page.IsValid) { Stream str = FileUpload1.PostedFile.InputStream; BinaryReader br = new BinaryReader(str); Byte[] size = br.ReadBytes((int)str.Length); DBHandler.DBHandler db = new DBHandler.DBHandler(con); Entities.personalInfo t1 = new Entities.personalInfo() { pKId = AID.Value, firstName = AFirstName.Value, middleName = AMiddleName.Value, lastName = ALastName.Value, iAm = Session["School"].ToString(), phone = APhoneNo.Value, emergencyContact = AEmergency.Value, cellNo = AMobNo.Value, eMail = AEmail.Value, enrollmentDate = AEnrollmentDate.Text, dOB = ADateOfBirth.Text, gender = Convert.ToInt32(DropDownList2.SelectedIndex.ToString()), userType = DropDownList1.SelectedValue, isActive = IsActive.Checked, isNew = IsNew.Checked, passCode = APassword.Value, address1 = AAdress1.Value, address2 = AAdress2.Value, address3 = AAdress3.Value, fileName = Path.GetFileName(FileUpload1.PostedFile.FileName), recordFile = size, }; db.insertTest(t1); SqlDataSource4.DataBind(); GridView3.DataBind(); } }
protected void ddlProjectYear_SelectedIndexChanged(object sender, EventArgs e) { var mgCookie = new ManageCookie(); users ck = mgCookie.ReadCookies(); if (ck == null) { return; } var departmentID = ddlDept.SelectedValue; var projectYear = ddlProjectYear.SelectedValue; if (string.IsNullOrEmpty(departmentID)) { return; } var strSql = new StringBuilder(); strSql.Append(string.Format(@"select pj_id, pj_code, d_id, pj_name, pj_year, pj_budget, pj_complete_status, pj_category, pj_approval_status, pj_lastupdate from projects where pj_status = 'real' and pj_complete_status = N'อยู่ในเกณฑ์การประเมิน' and d_id = {0}", departmentID)); if (!string.IsNullOrEmpty(projectYear)) { strSql.Append(string.Format(" and pj_year = '{0}'", projectYear)); } SqlDataSource4.SelectCommand = strSql.ToString(); SqlDataSource4.DataBind(); GridView1.DataSource = SqlDataSource4; GridView1.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { ManageCookie mgCookie = new ManageCookie(); users ck = mgCookie.ReadCookies(); //if (ViewState["pj_type"] == null) //{ // pj_type = ViewState["pj_type"]; //} //else //{ //} if (!Page.IsPostBack) { if (ck != null) { String strPJid = ck.pj_id; StringBuilder strSQL = new StringBuilder(); strSQL.Append("select d.d_code, d.d_name, m.mi_code, m.mi_name, p.pj_code, p.d_id, p.pj_name, y.yut_name, p.pj_year, p.pj_budget, pj_integrateProject, pj_relateDept, pj_background, pj_urgency, pj_type, pj_status "); strSQL.Append(" from projects p, department d, ministry m, yutasad y"); strSQL.Append(" where p.d_id = d.d_id and p.mi_id = m.mi_id and p.pj_yut_id = y.yut_id and p.pj_id = '" + strPJid + "'"); SqlDataSource4.SelectCommand = strSQL.ToString(); SqlDataSource4.DataBind(); DataView dv1 = (DataView)SqlDataSource4.Select(DataSourceSelectArguments.Empty); foreach (DataRow dRow in dv1.Table.Rows) { lblDeptCode.Text = dRow["mi_code"].ToString(); lblDeptName.Text = dRow["mi_name"].ToString(); lblDivisionCode.Text = dRow["d_code"].ToString(); lblDivisionName.Text = dRow["d_name"].ToString(); lblProjectName.Text = dRow["pj_name"].ToString(); lblProjectCode.Text = dRow["pj_code"].ToString(); lblYutasard.Text = dRow["yut_name"].ToString(); // lblIntegrateProject.Text = dRow["pj_integrateProject"].ToString(); // lblRelateDept.Text = dRow["pj_relateDept"].ToString(); lblBudget.Text = dRow["pj_budget"].ToString(); lblYear.Text = dRow["pj_year"].ToString(); ViewState["pj_type"] = dRow["pj_status"].ToString().ToLower().Trim(); pj_type = dRow["pj_status"].ToString().ToLower().Trim(); if (dRow["pj_status"].ToString().ToLower().Trim() == "sim") { //btnSubmitProject.Visible = false; pnlsubmit.Visible = false; btnEditProject.Visible = false; } else { //btnSubmitProject.Visible = true; pnlsubmit.Visible = true; btnEditProject.Visible = true; } } if (ck.pj_type == "sim") { pnlsubmit.Visible = false; } else { pnlsubmit.Visible = true; } } else { //redirect to login page } } projects pj = new projects(); string strStatus = pj.getProjectInfo(ck.pj_id, "pj_complete_status"); string strFrom = Request.QueryString["fm"] + ""; if (strFrom.ToLower() == "notreqapproval") { btnEditProject.Visible = false; pnlsubmit.Visible = false; linkreport2.Visible = false; linkreport3.Visible = false; } else if (strStatus != "ส่งผลแล้ว") { //btnSubmitProject.Enabled = true; btnEditProject.Enabled = true; pnlsubmit.Visible = true; } else { btnEditProject.Enabled = false; //btnSubmitProject.Enabled = false; pnlsubmit.Visible = false; Response.Redirect("project_summary_submitted.aspx"); } }
public void UpdateCourse() { SqlDataSource4.DataBind(); DropDownList3.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { ManageCookie mgCookie = new ManageCookie(); users ck = mgCookie.ReadCookies(); if (ck != null) { string strPJCode = ck.pj_code; string strPJStatus = ck.pj_status; string strPJ_ID = ck.pj_id; StringBuilder strSQL = new StringBuilder(); strSQL.Append("select d.d_code, d.d_name, m.mi_code, m.mi_name, p.pj_code, p.d_id, p.pj_name, y.yut_name, p.pj_year, p.pj_budget, pj_integrateProject, pj_relateDept, pj_filter_q1, pj_filter_q2 "); strSQL.Append(" from projects p, department d, ministry m, yutasad y"); strSQL.Append(" where p.d_id = d.d_id and p.mi_id = m.mi_id and p.pj_yut_id = y.yut_id and p.pj_id = " + strPJ_ID); SqlDataSource4.SelectCommand = strSQL.ToString(); SqlDataSource4.DataBind(); DataView dv1 = (DataView)SqlDataSource4.Select(DataSourceSelectArguments.Empty); if (dv1.Table.Rows.Count > 0) { foreach (DataRow dRow in dv1.Table.Rows) { lblDeptCode.Text = dRow["mi_code"].ToString(); lblDeptName.Text = dRow["mi_name"].ToString(); lblDivisionCode.Text = dRow["d_code"].ToString(); lblDivisionName.Text = dRow["d_name"].ToString(); lblProjectName.Text = dRow["pj_name"].ToString(); lblProjectCode.Text = dRow["pj_code"].ToString(); lblYutasard.Text = dRow["yut_name"].ToString(); lblIntegrateProject.Text = dRow["pj_integrateProject"].ToString(); lblRelateDept.Text = dRow["pj_relateDept"].ToString(); lblBudget.Text = dRow["pj_budget"].ToString(); lblYear.Text = dRow["pj_year"].ToString(); radQ1.SelectedValue = dRow["pj_filter_q1"].ToString(); radQ2.SelectedValue = dRow["pj_filter_q2"].ToString(); } radQ1.Enabled = false; radQ2.Enabled = false; if (radQ1.SelectedIndex == 1 || radQ2.SelectedIndex == 1) { lblResult.Text = "<span style='background-color:green;font-weight:bold'>เกณฑ์การประเมิน: แผนงาน / โครงการ อยู่ในเกณฑ์ที่ต้องวิเคราะห์ความเสี่ยงตามหลักธรรมาภิบาล</span>"; } else { lblResult.Text = "<span style='background-color:red;font-weight:bold'>เกณฑ์การประเมิน: แผนงาน / โครงการ นี้ไม่อยู่ในเกณฑ์ที่ต้องวิเคราะห์ความเสี่ยงตามหลักธรรมาภิบาล</span>"; } } else { //cannot display project details, redirect to login page } } else { //cannot find user login cookie, redirect to login page } } }
protected void Page_Load(object sender, EventArgs e) { ManageCookie mgCookie = new ManageCookie(); users ck = mgCookie.ReadCookies(); if (ck != null) { string strDeptID = ck.d_code; //Redirect Login users to pending page //redirectToPendingPage(); //string strDeptID = "01001"; string strProjectStatus = Request.QueryString["status"]; //keep project code in cookie for usage in follwing pages mgCookie.UpdateCookies("pj_status", strProjectStatus); string strSQL1 = "select * from dbo.department d, dbo.ministry m where d.mi_id = m.mi_id and d.d_code = '" + strDeptID + "'"; SqlDataSource4.SelectCommand = strSQL1; SqlDataSource4.DataBind(); DataView dv1 = (DataView)SqlDataSource4.Select(DataSourceSelectArguments.Empty); foreach (DataRow dRow in dv1.Table.Rows) { lblDeptCode.Text = dRow["mi_code"].ToString(); lblDeptName.Text = dRow["mi_name"].ToString(); lblDivisionCode.Text = dRow["d_code"].ToString(); lblDivisionName.Text = dRow["d_name"].ToString(); mgCookie.UpdateCookies("mi_id", dRow["mi_id"].ToString()); mgCookie.UpdateCookies("d_id", dRow["d_id"].ToString()); } if (!Page.IsPostBack) { string strSQL = string.Empty; strSQL = "SELECT pj_code from dbo.projects where d_id = " + strDeptID + " and pj_isinuse = 1 and pj_status = '" + strProjectStatus + "' and p_id = " + ck.p_id + " and mi_id is null and pj_name is null and pj_yut_id is null and pj_year is null"; SqlDataSource2.SelectCommand = strSQL; SqlDataSource2.DataBind(); DataView dv = (DataView)SqlDataSource2.Select(DataSourceSelectArguments.Empty); if (dv.Count > 0) { strSQL = "SELECT max(cast(substring(pj_code, 7, 3) as int)) from dbo.projects where d_id = " + strDeptID + " and pj_isinuse = 1 and pj_status = '" + strProjectStatus + "' and p_id = " + ck.p_id + " and mi_id is null and pj_name is null and pj_yut_id is null and pj_year is null"; } else { strSQL = "SELECT max(cast(substring(pj_code, 7, 3) as int)) + 1 from dbo.projects where d_id = " + strDeptID + " and pj_isinuse = 1 and pj_status = '" + strProjectStatus + "'"; } SqlDataSource2.SelectCommand = strSQL; SqlDataSource2.DataBind(); dv = (DataView)SqlDataSource2.Select(DataSourceSelectArguments.Empty); if (dv.Count > 0) { foreach (DataRow dRow in dv.Table.Rows) { if (dRow[0] != null && dRow[0].ToString() != string.Empty) { if (dRow[0].ToString().Length == 1) { lblProjectCode.Text = strDeptID + "-00" + dRow[0].ToString(); } else if (dRow[0].ToString().Length == 2) { lblProjectCode.Text = strDeptID + "-0" + dRow[0].ToString(); } else { lblProjectCode.Text = strDeptID + "-" + dRow[0].ToString(); } } else { lblProjectCode.Text = strDeptID + "-" + "001"; } } mgCookie.UpdateCookies("pj_code", lblProjectCode.Text); string strUID = ck.p_id; /************************************************************************************************** * insert projects table by setting projects.p_isinuse = 1, * this is to avoid conflict when creating more than 1 project at the same time by multiple users **************************************************************************************************/ SqlParameter pj_code = new SqlParameter("@pj_code", SqlDbType.NVarChar, 15); pj_code.Direction = ParameterDirection.Input; pj_code.Value = lblProjectCode.Text; SqlParameter p_id = new SqlParameter("@p_id", SqlDbType.Int); p_id.Direction = ParameterDirection.Input; p_id.Value = ck.p_id; SqlParameter pj_status = new SqlParameter("@pj_status", SqlDbType.NVarChar); pj_status.Direction = ParameterDirection.Input; pj_status.Value = strProjectStatus; SqlParameter d_id = new SqlParameter("@d_id", SqlDbType.NVarChar); d_id.Direction = ParameterDirection.Input; d_id.Value = strDeptID; insertParameters.Add(pj_code); insertParameters.Add(p_id); insertParameters.Add(pj_status); insertParameters.Add(d_id); try { //not insert when the existing record does not have input string strSQL11 = "select pj_id from projects where pj_code = '" + lblProjectCode.Text + "' and pj_status = '" + Request.QueryString["status"] + "'"; SqlDataSource7.SelectCommand = strSQL11; SqlDataSource7.DataBind(); DataView dv7 = (DataView)SqlDataSource7.Select(DataSourceSelectArguments.Empty); if (dv7.Table.Rows.Count == 0) { SqlDataSource3.Insert(); } else { mgCookie.UpdateCookies("pj_id", dv7.Table.Rows[0]["pj_id"].ToString()); } } catch (Exception ex) { //Elmah Elmah.ErrorSignal.FromCurrentContext().Raise(ex); } } } } }
protected void AddRecord() { int retIdentity = 0; try { SqlConnection conn = DBConnection(); string strsql1 = string.Format( @" select * from department where d_code = " + txtDCode.Text + " or d_name = '" + txtDName.Text + "'"); SqlDataAdapter da = new SqlDataAdapter(strsql1, conn); DataSet ds1 = new DataSet(); da.Fill(ds1); //DBConnection().Close(); if (ds1.Tables[0].Rows.Count > 0) { //code ซ้ำ ไม่สามาถ update ได้ lblResult.Text = "รหัสหน่วยงาน หรือ ชื่อหน่วยงาน นี้ถูกใช้โดยหน่วยงานอื่นแล้ว ไม่สามารถบันทึกได้"; } else { conn = DBConnection(); string strsql = string.Format( @" insert into department (d_id, d_name, d_code, mi_id) values (@d_id, @d_name, @d_code, @mi_id)"); SqlCommand cmd = new SqlCommand(strsql, conn); cmd.CommandType = CommandType.Text; cmd.Parameters.AddWithValue("@d_id", hdddeptid.Value); cmd.Parameters.AddWithValue("@mi_id", ddlMin.SelectedValue); cmd.Parameters.AddWithValue("@d_code", txtDCode.Text); cmd.Parameters.AddWithValue("@d_name", txtDName.Text); retIdentity = cmd.ExecuteNonQuery(); } } catch (Exception ex) { lblResult.Text = "ไม่สามารถเพิ่มหน่วยงานใหม่ได้ กรุณาลองใหม่อีกครั้ง"; //lblResult.Text = ex.Message; } finally { DBConnection().Close(); } if (retIdentity > 0) { lblResult.Text = "เพิ่มหน่วยงานใหม่สำเร็จ"; StringBuilder strSQL = new StringBuilder(); strSQL.Append("select m.mi_code, m.mi_name, d.d_name, d_code, d.d_id as d_id, d.id, m.mi_id from department d, ministry m "); strSQL.Append("where d.mi_id = m.mi_id and d.mi_id = " + ddlMin.SelectedValue); SqlDataSource4.SelectCommand = strSQL.ToString(); SqlDataSource4.DataBind(); GridView1.DataSource = SqlDataSource4; GridView1.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { ManageCookie mgCookie = new ManageCookie(); users ck = mgCookie.ReadCookies(); if (ck != null) { String strPJid = Request.QueryString["pjid"]; //Add by Itsada Jitchot 2014/04/30 เนื่องจากในการออกรายงานต้องการ pj_id ที่กดมาจากลิ้ง mgCookie.UpdateCookies("pj_id", strPJid); StringBuilder strSQL = new StringBuilder(); strSQL.Append("select d.d_code, d.d_name, m.mi_code, m.mi_name, p.pj_code, p.d_id, p.pj_name, y.yut_name, p.pj_year, p.pj_budget, pj_integrateProject, pj_relateDept, pj_background, pj_urgency, pj_type, pj_complete_status "); strSQL.Append(" from projects p, department d, ministry m, yutasad y"); strSQL.Append(" where p.d_id = d.d_id and p.mi_id = m.mi_id and p.pj_yut_id = y.yut_id and p.pj_id = '" + strPJid + "'"); SqlDataSource4.SelectCommand = strSQL.ToString(); SqlDataSource4.DataBind(); DataView dv1 = (DataView)SqlDataSource4.Select(DataSourceSelectArguments.Empty); foreach (DataRow dRow in dv1.Table.Rows) { lblDeptCode.Text = dRow["mi_code"].ToString(); lblDeptName.Text = dRow["mi_name"].ToString(); lblDivisionCode.Text = dRow["d_code"].ToString(); lblDivisionName.Text = dRow["d_name"].ToString(); lblProjectName.Text = dRow["pj_name"].ToString(); lblProjectCode.Text = dRow["pj_code"].ToString(); lblYutasard.Text = dRow["yut_name"].ToString(); lblBudget.Text = dRow["pj_budget"].ToString(); lblYear.Text = dRow["pj_year"].ToString(); } gUtilities gt = new gUtilities(); if (dv1.Table.Rows[0]["pj_complete_status"].ToString() == "ไม่อยู่ในเกณฑ์การประเมิน/กรอกสมบูรณ์") { linkreport2.Visible = false; linkreport3.Visible = false; litHeader.Text = " โครงการกรอกสมบูรณ์ที่ไม่อยู่ในข่ายที่ต้องวิเคราะห์ความเสี่ยง"; litRisk1.Text = "-"; litRisk2.Text = "-"; } else { linkreport2.Visible = true; linkreport3.Visible = true; litHeader.Text = "โครงการที่เข้าข่ายการวิเคราะห์ความเสี่ยงตามหลักธรรมาภิบาล"; litRisk1.Text = gt.getReportTammaTotal(ck.pj_id); litRisk2.Text = gt.getReportFactorRiskTotal(ck.pj_id); } } else { //redirect //Response.Redirect("project_summary.aspx"); } } }
protected void Page_Load(object sender, EventArgs e) { try { if (Session["status"] != null && Session["status"].ToString().Equals("1")) { Page.ClientScript.RegisterStartupScript(this.GetType(), "ErrorFunction", "errorMessages('Datele au fost actualizate cu succes!','success');", true); Session.Remove("status"); } } catch (Exception err) { } if (!Page.IsPostBack) { try { MembershipUser userCheck = System.Web.Security.Membership.GetUser(); if (userCheck != null) // bool userCheck = (System.Web.HttpContext.Current.User != null) && System.Web.HttpContext.Current.User.Identity.IsAuthenticated; // if (userCheck) { string username = System.Web.Security.Membership.GetUser().UserName.ToString(); string email = System.Web.Security.Membership.GetUser().Email.ToString(); string user = System.Web.Security.Membership.GetUser().ProviderUserKey.ToString(); Username.Text = username; Email.Text = email; string sqlVerif = "SELECT count(*) from PozeUseri where Id_User = @IdUser"; SqlConnection con = ConnectionFactory.getNewSqlConnection(); con.Open(); SqlCommand com = new SqlCommand(sqlVerif, con); com.Parameters.AddWithValue("IdUser", user); int userCount = (int)com.ExecuteScalar(); con.Close(); if (userCount > 0) { string sql = "SELECT Poza_User FROM PozeUseri WHERE Id_User = @IdUser"; con = ConnectionFactory.getNewSqlConnection(); con.Open(); com = new SqlCommand(sql, con); com.Parameters.AddWithValue("IdUser", user); try { SqlDataReader r = com.ExecuteReader(); while (r.Read()) { UserImage.ImageUrl = "~/pozeUseri/" + r["Poza_User"].ToString(); } } catch (Exception err) { } con.Close(); } else { UserImage.Attributes["src"] = "pozeUseri/DefaultUserIcon.png"; } string userId = System.Web.Security.Membership.GetUser().ProviderUserKey.ToString(); SqlDataSource3.SelectCommand = "SELECT Carti.Id AS CartiId, Carti.Titlu AS CartiTitlu, Carti.Poza_Coperta, Autori.Prenume + ' ' + Autori.Nume AS NumeAutor, Genuri.Gen FROM Carti INNER JOIN Genuri ON Carti.Id_Gen = Genuri.Id INNER JOIN Autori ON Carti.Id_Autor = Autori.Id INNER JOIN CartiFavorite ON Carti.Id = CartiFavorite.Id_Carte WHERE CartiFavorite.Id_User = @user"; SqlDataSource3.SelectParameters.Clear(); SqlDataSource3.SelectParameters.Add("user", userId); SqlDataSource3.DataBind(); SqlDataSource4.SelectCommand = "SELECT Carti.Id AS CartiId, Carti.Titlu AS CartiTitlu, Carti.Poza_Coperta, Autori.Prenume + ' ' + Autori.Nume AS NumeAutor, Genuri.Gen FROM Carti INNER JOIN Genuri ON Carti.Id_Gen = Genuri.Id INNER JOIN Autori ON Carti.Id_Autor = Autori.Id INNER JOIN CartiDeCitit ON Carti.Id = CartiDeCitit.Id_Carte WHERE CartiDeCitit.Id_User = @user"; SqlDataSource4.SelectParameters.Clear(); SqlDataSource4.SelectParameters.Add("user", userId); SqlDataSource4.DataBind(); SqlDataSource5.SelectCommand = "SELECT Carti.Id AS CartiId, Carti.Titlu AS CartiTitlu, Carti.Poza_Coperta, Autori.Prenume + ' ' + Autori.Nume AS NumeAutor, Genuri.Gen FROM Carti INNER JOIN Genuri ON Carti.Id_Gen = Genuri.Id INNER JOIN Autori ON Carti.Id_Autor = Autori.Id INNER JOIN CartiCitite ON Carti.Id = CartiCitite.Id_Carte WHERE CartiCitite.Id_User = @user"; SqlDataSource5.SelectParameters.Clear(); SqlDataSource5.SelectParameters.Add("user", userId); SqlDataSource5.DataBind(); } else { Response.Redirect("~/Home.aspx", false); } } catch (Exception err) { } } if (IsPostBack && UserProfilePicture.PostedFile != null) { try { if (UserProfilePicture.HasFile) { String type = UserProfilePicture.PostedFile.ContentType.ToLower(); System.Drawing.Image img = System.Drawing.Image.FromStream(UserProfilePicture.PostedFile.InputStream); int height = img.Height; int width = img.Width; decimal size = Math.Round(((decimal)UserProfilePicture.PostedFile.ContentLength / (decimal)1024), 2); if (size > 3500) { Page.ClientScript.RegisterStartupScript(this.GetType(), "ErrorFunction", "errorMessages('Imagine prea mare! Dimensiunea maxima pentru imagine este 3,5MB.', 'danger');", true); } else { if (type.Contains("jpg") || type.Contains("jpeg")) { string user = System.Web.Security.Membership.GetUser().ProviderUserKey.ToString(); UserProfilePicture.SaveAs(Server.MapPath("~/pozeUseri/") + user + ".jpg"); string sqlVerif = "SELECT count(*) from PozeUseri where Id_User = @IdUser"; SqlConnection con = ConnectionFactory.getNewSqlConnection(); con.Open(); SqlCommand com = new SqlCommand(sqlVerif, con); com.Parameters.AddWithValue("IdUser", user); int userCount = (int)com.ExecuteScalar(); con.Close(); if (userCount > 0) { string sql = "UPDATE PozeUseri SET Poza_User = @Poza WHERE Id_User = @IdUser"; con = ConnectionFactory.getNewSqlConnection(); con.Open(); com = new SqlCommand(sql, con); com.Parameters.AddWithValue("IdUser", user); string urlPoza = user + ".jpg"; com.Parameters.AddWithValue("Poza", urlPoza); com.ExecuteNonQuery(); con.Close(); UserImage.ImageUrl = "~/pozeUseri/" + urlPoza; } else { string sql = "INSERT INTO PozeUseri (Id_User, Poza_User) VALUES (@IdUser, @Poza)"; con = ConnectionFactory.getNewSqlConnection(); con.Open(); com = new SqlCommand(sql, con); com.Parameters.AddWithValue("IdUser", user); string urlPoza = user + ".jpg"; com.Parameters.AddWithValue("Poza", urlPoza); com.ExecuteNonQuery(); con.Close(); UserImage.ImageUrl = "~/pozeUseri/" + urlPoza; } //Page.ClientScript.RegisterStartupScript(this.GetType(), "ErrorFunction", "errorMessages('Imaginea au fost actualizata cu succes!','success');", true); //Session.Remove("status"); Session["status"] = "1"; Response.Redirect(Request.RawUrl, false); } //Response.Redirect(Request.RawUrl); //Server.TransferRequest(Request.Url.AbsolutePath, false); } } } catch (Exception err) { } } }
protected void Page_Load(object sender, EventArgs e) { try { if (Session["status"] != null && Session["status"].ToString().Equals("1")) { Page.ClientScript.RegisterStartupScript(this.GetType(), "ErrorFunction", "errorMessages('Multumim! Votul tau a fost inregistrat','success');", true); Session.Remove("status"); } if (Session["editBook"] != null && Session["editBook"].ToString().Equals("1")) { Page.ClientScript.RegisterStartupScript(this.GetType(), "ErrorFunction", "errorMessages('Date cartii au fost actualizate cu succes!','success');", true); Session.Remove("editBook"); } } catch (Exception err) { } if (!Page.IsPostBack) { string q = Request.Params["q"]; if (q != null) { try { q = Server.UrlDecode(q); SqlDataSource1.SelectCommand = "SELECT Carti.Id AS CartiId, Carti.Titlu AS CartiTitlu, Carti.Poza_Coperta, Carti.Text_Descriere, Genuri.Gen, Autori.Prenume + ' ' + Autori.Nume AS NumeAutor, ROUND(AVG(ISNULL(NoteDateCartilor.Nota, 0)), 0) AS MedieNote FROM Carti INNER JOIN Genuri ON Carti.Id_Gen = Genuri.Id INNER JOIN Autori ON Carti.Id_Autor = Autori.Id LEFT JOIN NoteDateCartilor ON Carti.Id = NoteDateCartilor.Id_Carte WHERE Carti.Id = @q GROUP BY Carti.Id, Carti.Titlu, Carti.Poza_Coperta, Carti.Text_Descriere, Genuri.Gen, Autori.Prenume + ' ' + Autori.Nume"; SqlDataSource1.SelectParameters.Clear(); SqlDataSource1.SelectParameters.Add("q", q); SqlDataSource1.DataBind(); bool check = (System.Web.HttpContext.Current.User != null) && System.Web.HttpContext.Current.User.Identity.IsAuthenticated; if (check) { string user = System.Web.Security.Membership.GetUser().ProviderUserKey.ToString(); string sqlVerif = "SELECT count(*) from PozeUseri where Id_user = @IdUser"; SqlConnection con = ConnectionFactory.getNewSqlConnection(); con.Open(); SqlCommand com = new SqlCommand(sqlVerif, con); com.Parameters.AddWithValue("IdUser", user); int userCount = (int)com.ExecuteScalar(); con.Close(); if (userCount > 0) { Image imagine = LoginView1.FindControl("ImgUserPicture2") as Image; imagine.ImageUrl = "~/pozeUseri/" + user + ".jpg"; } } SqlDataSource2.SelectCommand = "SELECT Comentarii.Id, Comentarii.Comentariu_Text, Comentarii.Data, Comentarii.Id_Carte, aspnet_Users.UserName, PozeUseri.Poza_User FROM aspnet_Users INNER JOIN Comentarii ON aspnet_Users.UserId = Comentarii.Id_User LEFT OUTER JOIN PozeUseri ON Comentarii.Id_User = PozeUseri.Id_User WHERE Comentarii.Id_Carte = @q"; SqlDataSource2.SelectParameters.Clear(); SqlDataSource2.SelectParameters.Add("q", q); SqlDataSource2.DataBind(); SqlDataSource3.SelectCommand = "SELECT TOP 10 Carti.Id AS CartiId, Carti.Titlu AS CartiTitlu, Carti.Poza_Coperta, Autori.Prenume + ' ' + Autori.Nume AS NumeAutor, Genuri.Gen FROM Carti INNER JOIN Genuri ON Carti.Id_Gen = Genuri.Id INNER JOIN Autori ON Carti.Id_Autor = Autori.Id WHERE (Genuri.Gen = (SELECT Genuri_1.Gen FROM Genuri AS Genuri_1 INNER JOIN Carti AS Carti_1 ON Genuri_1.Id = Carti_1.Id_Gen WHERE (Carti_1.Id = @q))) AND (Carti.Id <> (SELECT Id FROM Carti AS Carti_2 WHERE (Id = @q))) ORDER BY NEWID()"; SqlDataSource3.SelectParameters.Clear(); SqlDataSource3.SelectParameters.Add("q", q); SqlDataSource3.DataBind(); SqlDataSource4.SelectCommand = "SELECT Edituri.Editura, Edituri.Site_Editura FROM CartiApartinDeEdituri INNER JOIN Edituri ON CartiApartinDeEdituri.Id_Editura = Edituri.Id INNER JOIN Carti ON CartiApartinDeEdituri.Id_Carte = Carti.Id WHERE Carti.Id = @q"; SqlDataSource4.SelectParameters.Clear(); SqlDataSource4.SelectParameters.Add("q", q); SqlDataSource4.DataBind(); } catch (Exception err) { } } else { Response.Redirect("~/Home.aspx"); } } }
protected void DropDownListCat_SelectedIndexChanged(object sender, EventArgs e) { SqlDataSource4.SelectCommand = "SELECT DISTINCT Producto.ID_Producto,stuff((Select ', ' + OEM.OEM From OEM inner join Marca on OEM.ID_Marca = Marca.ID_Marca Where OEM.ID_Producto = Producto.ID_Producto For XML Path('')), 1,2,'') AS LISTAOEM , stuff((Select ', ' + CodigoProducto.Codigo From CodigoProducto inner join MarcaProd on CodigoProducto.ID_MaraProd = MarcaProd.ID_MaraProd Where CodigoProducto.ID_Producto = Producto.ID_Producto For XML Path('')), 1,2,'') AS LISTACODP,Producto.Descripcion, stuff((Select '| ' + Marca +', '+ Modelo + ', ' + Rubro + ' ~ ' + AnioInicio + '-'+AnioFinal From Marca inner join Modelo on Marca.ID_Marca = Modelo.ID_Marca inner join Rubro on Modelo.ID_Modelo = Rubro.ID_Modelo inner join AnioProducto on Rubro.ID_Rubro = AnioProducto.ID_Rubro Where AnioProducto.ID_Producto = Producto.ID_Producto For XML Path('')), 1,2,'') AS LISTANIOP,SubCategoria.SubCategoria+', '+ Categoria.Categoria AS Categoria, CAST(MarcaProd.ID_MaraProd AS VARCHAR) + ', '+ MarcaProd.MarcaP AS MarcaP, Stock.PrecioVenta, Stock.Cantidad, Stock.PrecioUnitario, Stock.Ubicacion, Medida.Medida, Tienda.Tienda, Stock.ID_Existencia FROM Medida INNER JOIN Stock INNER JOIN Tienda ON Stock.ID_Tienda = Tienda.ID_Tienda INNER JOIN Producto ON Stock.ID_Producto = Producto.ID_Producto INNER JOIN SubCategoria ON Producto.ID_SubCategoria = SubCategoria.ID_SubCategoria ON Medida.ID_Medida = Stock.ID_Medida INNER JOIN MarcaProd ON Stock.ID_MaraProd = MarcaProd.ID_MaraProd INNER JOIN Categoria ON SubCategoria.ID_Categoria = Categoria.ID_Categoria inner join OEM on Producto.ID_Producto = OEM.ID_Producto inner join CodigoProducto on Producto.ID_Producto = CodigoProducto.ID_Producto inner join AnioProducto on Producto.ID_Producto = AnioProducto.ID_Producto Where Tienda.ID_Tienda = " + Session["IDtienda"].ToString() + " AND SubCategoria.ID_Categoria =" + DropDownListCat.SelectedValue; SqlDataSource4.DataBind(); }
protected void Button11_Click(object sender, EventArgs e) { SqlDataSource4.SelectCommand = "SELECT Modelo.ID_Modelo, Modelo.Modelo, Modelo.ID_Marca, Marca.Marca FROM Modelo INNER JOIN Marca ON Modelo.ID_Marca = Marca.ID_Marca WHERE Modelo like '%" + TextBox2.Text + "%'"; SqlDataSource4.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { userManager theUserManager = (userManager)Session["theUserManager"]; theCompanyCode = theUserManager.getCompanyCode(); theUserId = theUserManager.getUserId(); theUserName = theUserManager.getUserName(); theUserCode = theUserManager.getUserCode(); theProgramCode = "atpu1C00"; //初始化站点名称begin if (Request["opFlag"] == "getEditZD") { string str1 = ""; string zdmc = Request["zddmC"].ToString(); string sql = "select STATION_CODE from CODE_STATION where STATION_NAME='" + zdmc + "'"; dc.setTheSql(sql); if (dc.GetTable().Rows.Count == 0) { str1 = ""; this.Response.Write(str1); this.Response.End(); return; } string zddm = dc.GetTable().Rows[0][0].ToString(); if (zdmc == "") { str1 = ""; this.Response.Write(str1); this.Response.End(); return; } str1 = zddm; this.Response.Write(str1); this.Response.End(); } //初始化站点名称end //初始化零件名称begin if (Request["opFlag"] == "getEditLJDM") { string str1 = ""; string ljdm = Request["ljdmC"].ToString(); string sql = "select PT_DESC2 from COPY_PT_MSTR where PT_PART='" + ljdm + "'"; dc.setTheSql(sql); if (dc.GetTable().Rows.Count == 0) { str1 = ""; this.Response.Write(str1); this.Response.End(); return; } string ljmc = dc.GetTable().Rows[0][0].ToString(); if (ljdm == "") { str1 = ""; this.Response.Write(str1); this.Response.End(); return; } str1 = ljmc; this.Response.Write(str1); this.Response.End(); } //初始化零件名称end if (Request["opFlag"] == "getEditSeries") { string str = ""; string pcode = Request["PCode"].ToString().Trim(); //dataConn theDataConn = new dataConn(" select FUNC_GET_PLANSITE('" + pcode + "','D')from dual"); //theDataConn.OpenConn(); //string gQadSite = theDataConn.GetValue(); //if (gQadSite != "") //{ string sql = "SELECT distinct STATION_NAME FROM CODE_STATION where PLINE_CODE=RH_GET_DATA('L','" + pcode + "','','','')"; Session["1C00STATION"] = sql; SqlDataSource2.SelectCommand = sql; SqlDataSource2.DataBind(); //} this.Response.Write(str); this.Response.End(); } setCondition(); //string Sql2 = "SELECT distinct STATION_NAME FROM CODE_STATION order by STATION_NAME "; //SqlDataSource2.SelectCommand = Sql2; //SqlDataSource2.DataBind(); //SqlDataSource22.SelectCommand = Sql2; //SqlDataSource22.DataBind(); string Sql3 = "SELECT distinct PT_PART,PT_DESC2 FROM COPY_PT_MSTR where pt_phantom=0 order by PT_PART "; SqlDataSource3.SelectCommand = Sql3; SqlDataSource3.DataBind(); string Sql4 = "select a.pline_code,b.rmes_id,b.pline_name from VW_USER_ROLE_PROGRAM a " + "left join code_product_line b on a.pline_code=b.pline_code " + "where a.COMPANY_CODE = '" + theCompanyCode + "' and a.user_id='" + theUserId + "' and a.program_code='" + theProgramCode + "' order by b.PLINE_NAME"; SqlDataSource4.SelectCommand = Sql4; SqlDataSource4.DataBind(); string Sql8 = "select internal_code,internal_name from code_internal " + "where COMPANY_CODE = '" + theCompanyCode + "' and internal_type_code='011' order by internal_code"; SqlLJLB.SelectCommand = Sql8; SqlLJLB.DataBind(); //if (!IsPostBack) //{ // string sql = "SELECT distinct STATION_NAME FROM CODE_STATION "; // Session["1C00STATION"] = sql; // SqlDataSource2.SelectCommand = sql; // SqlDataSource2.DataBind(); //} }
protected void UpdateRecordByID(string d_id) { int retIdentity = 0; try { SqlConnection conn = DBConnection(); string strsql1 = string.Format(@" select * from department where (d_code = " + txtDCode.Text + " or d_name = '" + txtDName.Text + "') and id != " + d_id); SqlDataAdapter da = new SqlDataAdapter(strsql1, conn); DataSet ds1 = new DataSet(); da.Fill(ds1); // string strsql2 = string.Format(@" // select * from department where (d_code = " + txtDCode.Text + " and d_name = '" + txtDName.Text + "') and id != " + d_id); // SqlDataAdapter da1 = new SqlDataAdapter(strsql2, conn); // DataSet ds2 = new DataSet(); // da1.Fill(ds2); //if (ds2.Tables[0].Rows.Count > 0) //{ // lblResult.Text = "บันทึกการแก้ไขสำเร็จ"; //} //else if (ds1.Tables[0].Rows.Count > 0) { //รหัสหน่วยงานซ้ำ หรือ ชื่อหน่วยงานซ้ำ ไม่สามาถ update ได้ lblResult.Text = "รหัสหน่วยงาน หรือ ชื่อหน่วยงาน นี้ถูกใช้โดยหน่วยงานอื่นแล้ว ไม่สามารถบันทึกได้"; } else { string strsql = string.Format(@" update department set d_code = @d_code, d_name = @d_name where id = @id"); SqlCommand cmd = new SqlCommand(strsql, conn); cmd.CommandType = CommandType.Text; cmd.Parameters.AddWithValue("@id", hdddeptid.Value); cmd.Parameters.AddWithValue("@d_code", txtDCode.Text); cmd.Parameters.AddWithValue("@d_name", txtDName.Text); retIdentity = cmd.ExecuteNonQuery(); } } catch (Exception ex) { lblResult.Text = "ไม่สามารถบันทึกได้ กรุณาลองใหม่อีกครั้ง"; //lblResult.Text = ex.Message; } finally { DBConnection().Close(); } if (retIdentity > 0) { lblResult.Text = "บันทึกการแก้ไขสำเร็จ"; StringBuilder strSQL = new StringBuilder(); strSQL.Append("select m.mi_code, m.mi_name, d.d_name, d_code, d.d_id as d_id, d.id, m.mi_id from department d, ministry m "); strSQL.Append("where d.mi_id = m.mi_id and d.mi_id = " + ddlMin.SelectedValue); SqlDataSource4.SelectCommand = strSQL.ToString(); SqlDataSource4.DataBind(); GridView1.DataSource = SqlDataSource4; GridView1.DataBind(); } }