示例#1
0
    protected void btnGrid2Save_Click(object sender, EventArgs e)//
    {
        List <string> commandlist = new List <string>();

        MSYS.DAL.DbOperator opt = new MSYS.DAL.DbOperator();
        foreach (GridViewRow row in GridView2.Rows)
        {
            int    rowIndex = row.RowIndex;
            string id       = GridView2.DataKeys[rowIndex].Value.ToString();
            string status   = ((DropDownList)row.FindControl("listGrid2Status")).SelectedValue;
            if ((status == "1" || status == "2") && ((TextBox)row.FindControl("txtGridpos")).Text != "")
            {
                string[] seg   = { "section", "equipment_id", "position", "pointnum", "luboil", "periodic", "style", "amount", "CREATE_TIME", "MAIN_ID", "STATUS" };
                string[] value = { ((DropDownList)row.FindControl("listGridsct")).SelectedValue, ((DropDownList)row.FindControl("listGridEq")).SelectedValue, ((TextBox)row.FindControl("txtGridpos")).Text, ((TextBox)row.FindControl("txtGridnum")).Text, ((TextBox)row.FindControl("txtGridoil")).Text, ((TextBox)row.FindControl("txtGriPric")).Text, ((TextBox)row.FindControl("txtGridStyle")).Text, ((TextBox)row.FindControl("txtGridamount")).Text, System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), hdcode.Value, "2" };
                commandlist.Add(opt.UpdateStr(seg, value, "ht_eq_lb_plan_detail", " where ID = '" + id + "'"));
            }
        }
        if (commandlist.Count > 0)
        {
            string log_message = opt.TransactionCommand(commandlist) == "Success" ? "润滑记录录入成功" : "润滑记录录入失败";
            InsertTlog(log_message);
            bindGrid2(txtCode.Value);

            string alter = opt.GetSegValue("select case  when total = done then 1 else 0 end as status from (select  count(distinct t.id) as total,count( distinct t1.id) as done from ht_eq_lb_plan_detail t left join ht_eq_lb_plan_detail t1 on t1.id = t.id and t1.status >= '2' and t1.is_del = '0' where t.main_id = '" + hdcode.Value + "'  and t.is_del = '0')", "status");
            if (alter == "1")
            {
                opt.UpDateOra("update ht_eq_lb_plan set TASK_STATUS = '2' where PZ_CODE = '" + hdcode.Value + "'  and TASK_STATUS = '1'");
                bindGrid1();
            }
        }
    }