protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { int rowindex = Convert.ToInt32(e.CommandArgument); GridViewRow row = GridView1.Rows[rowindex]; int cprjidx = cc1.getcolumnindexbynameint(row, "cprj"); int lineidx = cc1.getcolumnindexbynameint(row, "line"); int cindex = cc1.getcolumnindexbynameint(row, "nopr"); string pristr1 = cc1.getcolumnindexbyname(row, "cprj"); string pristr2 = cc1.getcolumnindexbyname(row, "line"); string pristr3 = cc1.getcolumnindexbyname(row, "nopr"); string[] emno_colarray = Request.Form["emno"].Split(','); string specific_rowemno = emno_colarray[rowindex]; Button ab = (Button)e.CommandSource; Button ab2 = new Button(); GridViewRow myrow = (GridViewRow)ab.NamingContainer; if (e.CommandName == "updcomd") { ab2 = (Button)GridView1.Rows[myrow.DataItemIndex].FindControl("updbtn"); } else if (e.CommandName == "addempl") { ScriptManager.RegisterStartupScript(Page, Page.GetType(), "sendSignals", "getSpecificEmpl();", true); } try { if (ab2.ID == "updbtn") { this.cc1.connectionofc008_modify("update ecsfc929_memb set emno='" + specific_rowemno + "' where cprj='" + pristr1 + "' and line='" + pristr2 + "' and nopr='" + pristr3 + "'"); } } catch (Exception ex) { } GVBind(); }
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { //--------var---------sn string control_str = string.Empty; Button ab = new Button(); Button ab2 = new Button(); Button ab3 = new Button(); //--------var---------en int index = Convert.ToInt32(e.CommandArgument); GridViewRow row = GridView1.Rows[index]; int cprjidx = cc1.getcolumnindexbynameint(row, "cprj"); int lineidx = cc1.getcolumnindexbynameint(row, "line"); int cindex = cc1.getcolumnindexbynameint(row, "nopr"); int findex = cc1.getcolumnindexbynameint(row, "完工日期"); string pristr1 = cc1.getcolumnindexbyname(row, "cprj"); string pristr2 = cc1.getcolumnindexbyname(row, "line"); string pristr3 = cc1.getcolumnindexbyname(row, "nopr"); string nloc = cc1.getcolumnindexbyname(row, "nloc"); string t_name = cc1.getcolumnindexbyname(row, "t_name"); string mkind = cc1.getcolumnindexbyname(row, "mkind"); string position = cc1.getcolumnindexbyname(row, "position"); string sdate = DateTime.Now.ToString("yyyy-MM-dd"); string sdtim = DateTime.Now.ToString("HH:mm"); string sdtim2 = DateTime.Now.ToString("HHmm"); //0826修改出get templatefield的columindex的方法 //以往只能用bindfield 的datafield屬性來抓 //但抓出key後若用其抓取控制項的text值則此控制項必須為asp.net之控制項(否則只會抓出"") //(若為html之控制項則加上屬性runat="server"即可使用, //但若html控制項被包在(目前已知:ajax)標籤內且此控制項的type若有特定 //屬性(如此處使用type="datetime-local")則因其不屬updatepanel標籤類別之下 //會發生錯誤 //string fintime = cc1.getcolumnindexbyname(row, "完工日期"); //-----------request.form抓取form中name為datel的欄位全值(預設使用','分隔)--------sn string[] date_colarray = Request.Form["datel"].Split(','); string specific_rowdate = date_colarray[index]; //-----------request.form--------------------------------------------------------en // string[] emno_colarray = Request.Form["emno"].Split(','); string specific_rowemno = emno_colarray[index]; // ab = (Button)e.CommandSource; GridViewRow myrow = (GridViewRow)ab.NamingContainer; if (e.CommandName == "afs") { ab2 = (Button)GridView1.Rows[myrow.DataItemIndex].FindControl("amend_finish_status"); } else if (e.CommandName == "getnowtime") { ab3 = (Button)GridView1.Rows[myrow.DataItemIndex].FindControl("getnowtime"); } control_str = ab2.Text.ToString(); if (ab2.ID == "amend_finish_status") { if (specific_rowdate != "") { DateTime convtodt = Convert.ToDateTime(specific_rowdate); string datestr = convtodt.ToString("yyyy-MM-dd"); string timestr = convtodt.ToString("HHmm"); if (Convert.ToInt32(Session["change_mode"]) == 1 && specific_rowdate != "") { int countofgroup933 = Convert.ToInt32(cc1.connectionofc008_select("select count(*) as cot from ecsfc933_mdt where cprj='" + pristr1 + "' and line='" + pristr2 + "' and nopr='" + pristr3 + "'", "cot")); int countisnull = Convert.ToInt32(cc1.connectionofc008_select("select count(*) as nullq from ecsfc929_memb as t1 inner join ecsfc933_mdt as t2 on t1.cprj=t2.cprj and t1.line=t2.line and t1.nopr=t2.nopr where t1.cprj='" + pristr1 + "' and t1.line='" + pristr2 + "' and t1.nopr='" + pristr3 + "' and (t2.sdate is NULL and t2.edate is NULL)", "nullq")); string msfid = this.cc1.connectionofc008_select(@"select msfid from ecsfc929_memb where cprj='" + pristr1 + "' and line='" + pristr2 + "' and nopr='" + pristr3 + "'", "msfid"); if (countisnull > 0)//休停中 { if (Session["SF_SPTrigger"].ToString().Trim() == "0") { string seconddata = this.cc1.connectionofc008_select(@"select top 1 t1 from (select top 2 msfid as t1,cprj from ecsfc933_mdt where cprj='" + pristr1 + "' and line='" + pristr2 + "' and nopr='" + pristr3 + "' order by t1 desc) ecsfc933_mdt order by t1 asc", "t1"); this.cc1.connectionofc008_modify(@"update ecsfc929_memb set edate=t2.edate ,edtim=t2.edtim ,msfid=t2.msfid ,pfc='是',statuscode='6' from ecsfc929_memb as t1 inner join ecsfc933_mdt as t2 on t1.cprj=t2.cprj and t1.line=t2.line and t1.nopr=t2.nopr where t2.msfid='" + seconddata + "'"); this.cc1.connectionofc008_modify(@"delete from ecsfc933_mdt where cprj='" + pristr1 + "' and line='" + pristr2 + "' and nopr='" + pristr3 + "' and sdate is NULL and edate is NULL"); int totalt = Convert.ToInt32(cc1.connectionofc008_select("select autm from ecsfc929_memb where cprj='" + pristr1 + "' and line='" + pristr2 + "' and nopr='" + pristr3 + "'", "autm")); Task.Run(() => cc1.RunCommandAsynchronously("update rp3440.baan.baan.tecsfc929230 set t_edat='" + sdate + "',t_etim='" + sdtim2 + "',t_autm='" + totalt + "' where t_cprj='" + pristr1 + "' and t_line='" + pristr2 + "' and t_nopr='" + pristr3 + "'")); //休停中完工 ScriptManager.RegisterStartupScript(Page, Page.GetType(), "sendSignals", "cprj='" + pristr1 + "';line='" + pristr2 + "';nloc='" + nloc + "';posi='" + position + "';t_name='" + t_name + "';mkind='" + mkind + "';$('#FinishBtn').click();", true); } else { this.cc1.connectionofc008_modify("update ecsfc933_mdt set sdate='" + sdate + "',sdtim='" + sdtim2 + "',memno='" + Session["emplnet2"] + "' where msfid=(select top 1 msfid from ecsfc933_mdt as t2 where cprj='" + pristr1 + "' and line='" + pristr2 + "' and nopr='" + pristr3 + "' order by msfid desc)"); this.cc1.connectionofc008_modify(@"update ecsfc929_memb set statuscode='1' where cprj='" + pristr1 + "' and line='" + pristr2 + "' and nopr='" + pristr3 + "'"); //補開始?? //ScriptManager.RegisterStartupScript(Page, Page.GetType(), "sendSignals", "cprj='" + pristr1 + "';line='" + pristr2 + "';nloc='" + nloc + "';posi='" + position + "';t_name='" + t_name + "';$('#StartBtn').click();", true); } } else//進行中 { if (Session["SF_SPTrigger"].ToString().Trim() == "0") { int totalm = connectionofc008_selectarray("select sdate,stuff(right('0000'+cast(sdtim as nvarchar),4),3,0,':') as sdt,edate,stuff(right('0000'+cast(edtim as nvarchar),4),3,0,':') as edt from ecsfc933_mdt where cprj='" + pristr1 + "' and line='" + pristr2 + "' and nopr='" + pristr3 + "'", countofgroup933); this.cc1.connectionofc008_modify(@"update ecsfc929_memb set edate='" + sdate + "',edtim='" + sdtim2 + "',pfc='是',autm='" + totalm + "',statuscode='6' where cprj='" + pristr1 + "' and line='" + pristr2 + "' and nopr='" + pristr3 + "'"); this.cc1.connectionofc008_modify("update ecsfc933_mdt set memno='" + Session["emplnet2"] + "' from ecsfc929_memb as t1 left join ecsfc933_mdt as t2 on t1.cprj=t2.cprj and t1.line=t2.line and t1.nopr=t2.nopr where t1.cprj='" + pristr1 + " ' and t1.line='" + pristr2 + "' and t1.nopr='" + pristr3 + "' and t1.msfid=t2.msfid"); Task.Run(() => cc1.RunCommandAsynchronously("update rp3440.baan.baan.tecsfc929230 set t_edat='" + sdate + "',t_etim='" + sdtim2 + "',t_autm='" + totalm + "' where t_cprj='" + pristr1 + "' and t_line='" + pristr2 + "' and t_nopr='" + pristr3 + "'")); //進行中完工 ok ScriptManager.RegisterStartupScript(Page, Page.GetType(), "sendSignals", "cprj='" + pristr1 + "';line='" + pristr2 + "';nloc='" + nloc + "';posi='" + position + "';t_name='" + t_name + "';mkind='" + mkind + "';$('#FinishBtn').click();", true); } else { this.cc1.connectionofc008_modify("update ecsfc933_mdt set edate='" + sdate + "',edtim='" + sdtim2 + "',memno='" + Session["emplnet2"] + "' where msfid=(select top 1 msfid from ecsfc933_mdt as t2 where cprj='" + pristr1 + "' and line='" + pristr2 + "' and nopr='" + pristr3 + "' order by msfid desc)"); this.cc1.connectionofc008_modify(@"update ecsfc929_memb set statuscode='2' where cprj='" + pristr1 + "' and line='" + pristr2 + "' and nopr='" + pristr3 + "'"); //補休停 ok ScriptManager.RegisterStartupScript(Page, Page.GetType(), "sendSignals", "cprj='" + pristr1 + "';line='" + pristr2 + "';nloc='" + nloc + "';posi='" + position + "';t_name='" + t_name + "';mkind='" + mkind + "';$('#PauseBtn').click();", true); } } } else if (Session["SF_SPTrigger"].ToString().Trim() != "1")//開工 { if (pristr3 != "1") { Global.tempint1 = Convert.ToInt32(pristr3) - 1; Global.tempvar2 = cc1.connectionofc008_select("select pfc from ecsfc929_memb where cprj='" + pristr1 + "' and line='" + pristr2 + "' and nopr='" + Global.tempint1 + "'", "pfc"); } //if (Global.tempvar2 == "是" || pristr3 == "1") //{ this.cc1.connectionofc008_modify(@"insert into ecsfc933_mdt(cprj,line,nopr,sdate,sdtim,emno,memno) values('" + pristr1 + "','" + pristr2 + "','" + pristr3 + "','" + datestr + "','" + timestr + "','" + specific_rowemno + "','" + Session["emplnet"].ToString() + "')"); this.cc1.connectionofc008_modify(@"update ecsfc929_memb set sdate='" + datestr + "',sdtim='" + timestr + "',code='*',statuscode='1' where cprj='" + pristr1 + "'and line='" + pristr2 + "' and nopr='" + pristr3 + "'"); Task.Run(() => cc1.RunCommandAsynchronously("update rp3440.baan.baan.tecsfc929230 set t_sdat='" + datestr + "',t_stim='" + timestr + "',t_code='*' where t_cprj='" + pristr1 + "' and t_line='" + pristr2 + "' and t_nopr='" + pristr3 + "'")); if (pristr2.Trim() == "P722") { Task.Run(() => cc1.RunCommandAsynchronously("update rp3440.baan.baan.tecsfc914230 set " + "t_adat_" + pristr3 + "='" + datestr + "' where t_cprj='" + pristr1 + "' and t_line='" + pristr2 + "'")); } if (pristr3 == "1" && cc1.connectionofc008_select("select distinct (case when(select t2.sdate from ecsfc929_memb as t2 where t2.cprj=t1.cprj and t2.nopr='1')<=t914.t_pdat_1 then 1 else 0 end) as InTime from ecsfc929_memb as t1 left join rp3440.baan.baan.tecsfc914230 as t914 on t1.cprj=t914.t_cprj and t1.line=t914.t_line where t1.cprj='" + pristr1 + "' and t1.line='" + pristr2 + "'", "InTime") == "0") { cc1.ReCalPreDate(pristr1, pristr2); } Session["change_mode"] = 1; //補開工 ScriptManager.RegisterStartupScript(Page, Page.GetType(), "sendSignals", "cprj='" + pristr1 + "';line='" + pristr2 + "';nloc='" + nloc + "';posi='" + position + "';t_name='" + t_name + "';mkind='" + mkind + "';$('#StartBtn').click();", true); //} //else // System.Web.UI.ScriptManager.RegisterStartupScript(this, this.GetType(), "opennewwindow", "alert('前一工程未完工不可補開目標工程!!');", true); } else { //補開始 this.cc1.connectionofc008_modify("update ecsfc933_mdt set sdate='" + sdate + "',sdtim='" + sdtim2 + "',memno='" + Session["emplnet2"] + "' where msfid=(select top 1 msfid from ecsfc933_mdt as t2 where cprj='" + pristr1 + "' and line='" + pristr2 + "' and nopr='" + pristr3 + "' order by msfid desc)"); //System.Web.UI.ScriptManager.RegisterStartupScript(this, this.GetType(), "opennewwindow", "alert('目前為補開工模式!!');", true); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "sendSignals", "cprj='" + pristr1 + "';line='" + pristr2 + "';nloc='" + nloc + "';posi='" + position + "';t_name='" + t_name + "';mkind='" + mkind + "';$('#SNlocBtn').click();", true); } GVBind(); } else { ScriptManager.RegisterStartupScript(Page, Page.GetType(), "nulltip2", "nulltip2();", true); } } else if (ab3.ID == "getnowtime") { Session["nowtrigger"] = pristr1 + pristr2 + pristr3; GVBind(); } }