Exemple #1
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        MSYS.DAL.DbOperator opt   = new MSYS.DAL.DbOperator();
        string[]            seg   = { "INSPECT_CODE", "INSPECT_GROUP", "INSPECT_NAME", "INSPECT_TYPE", "REMARK", "CREATE_ID", "CREATE_TIME", "UNIT" };
        string[]            value = { txtCode.Text, listSection2.SelectedValue, txtName.Text, listType2.SelectedValue, txtRemark.Text, listCreator.SelectedValue, System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), txtUnit.Text };

        string log_message = opt.MergeInto(seg, value, 1, "ht_qlt_inspect_proj") == "Success" ? "保存工艺检查项目成功" : "保存工艺检查项目失败";

        if (log_message == "保存工艺检查项目成功")
        {
            string[] procseg    = { };
            object[] procvalues = { };
            if (listSection2.SelectedValue == "4")
            {
                opt.ExecProcedures("Create_Sensor_Report", procseg, procvalues);
            }
            else if (listSection2.SelectedValue.Length == 1 && listSection2.SelectedValue != "4")
            {
                opt.ExecProcedures("Create_phychem_Report", procseg, procvalues);
            }
            else
            {
                opt.ExecProcedures("Create_process_Report", procseg, procvalues);
            }
        }
        log_message += "--详情:" + string.Join(",", value);
        InsertTlog(log_message);


        bindGrid();

        ScriptManager.RegisterStartupScript(UpdatePanel2, this.Page.GetType(), "", " $('.shade').fadeOut(100);", true);
    }
Exemple #2
0
    protected void btnDel1_Click(object sender, EventArgs e)
    {
        MSYS.DAL.DbOperator opt         = new MSYS.DAL.DbOperator();
        List <string>       commandlist = new List <string>();

        commandlist.Add("update HT_PUB_TECH_SECTION set IS_DEL = '1' where SECTION_CODE = '" + txtCode_1.Text + "'");
        //commandlist.Add("update ht_pub_inspect_process set IS_DEL = '1' where substr(PROCESS_CODE,1,5) = '" + txtCode.Text + "'");
        commandlist.Add("update HT_PUB_TECH_PARA set IS_DEL = '1' where substr(PARA_CODE,1,5) =  '" + txtCode_1.Text + "'");
        string log_message;

        if (opt.TransactionCommand(commandlist) == "Success")
        {
            log_message = "删除工艺段成功";
            tvHtml      = InitTree();
            opt.bindDropDownList(listSection_2, "select section_code,section_name from ht_pub_tech_section where is_del = '0' and is_valid = '1' order by section_code", "section_name", "section_code");
            opt.bindDropDownList(listSection, "select section_code,section_name from ht_pub_tech_section where is_valid = '1' and is_del = '0' order by section_code", "section_name", "section_code");
            string[] procseg    = { };
            object[] procvalues = { };
            opt.ExecProcedures("Create_Online_month_Report", procseg, procvalues);
            ScriptManager.RegisterStartupScript(UpdatePanel4, this.Page.GetType(), "sucess", "initTree();alert('删除成功');", true);
        }
        else
        {
            log_message = "删除工艺段失败";
        }
        log_message += ",工艺段ID:" + txtCode_1.Text;
        InsertTlog(log_message);
    }
Exemple #3
0
    protected void btnModify1_Click(object sender, EventArgs e)
    {
        MSYS.DAL.DbOperator opt = new MSYS.DAL.DbOperator();

        {
            string[] seg   = { "SECTION_CODE", "SECTION_NAME", "REMARK", "IS_PATH_CONFIG", "CREATE_ID", "CREATE_TIME" };
            string[] value = { txtCode_1.Text, txtName_1.Text, txtDscrp_1.Text, Convert.ToInt16(rdValid_1.Checked).ToString(), ((MSYS.Data.SysUser)Session["user"]).id, System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") };
            string   log_message;
            if (opt.MergeInto(seg, value, 1, "HT_PUB_TECH_SECTION") == "Success")
            {
                log_message = "保存工艺段成功";
                tvHtml      = InitTree();
                opt.bindDropDownList(listSection_2, "select section_code,section_name from ht_pub_tech_section where is_del = '0' and is_valid = '1' order by section_code", "section_name", "section_code");
                opt.bindDropDownList(listSection, "select section_code,section_name from ht_pub_tech_section where is_valid = '1' and is_del = '0' order by section_code", "section_name", "section_code");

                string[] procseg    = { };
                object[] procvalues = { };
                opt.ExecProcedures("Create_Online_month_Report", procseg, procvalues);

                ScriptManager.RegisterStartupScript(UpdatePanel4, this.Page.GetType(), "sucess", "initTree();alert('保存成功');", true);
            }
            else
            {
                log_message = "保存工艺段失败";
            }
            log_message += "--数据详情:" + string.Join("-", value);
            InsertTlog(log_message);
        }
    }
Exemple #4
0
    protected void btnModify_Click(object sender, EventArgs e)
    {
        MSYS.DAL.DbOperator opt = new MSYS.DAL.DbOperator();
        if (txtCode.Text.Length == 10 && txtCode.Text.Substring(0, 5) == listSection.SelectedValue)
        {
            string   oldepath = opt.GetSegValue("select * from HT_PUB_TECH_PARA where PARA_CODE = '" + txtCode.Text + "'", "PATH_NODE");
            string[] seg      = { "PARA_CODE", "PARA_NAME", "PARA_UNIT", "PARA_TYPE", "REMARK", "IS_VALID", "CREATE_ID", "CREATE_TIME", "EQUIP_CODE", "SET_TAG", "VALUE_TAG", "BUSS_ID", "PATH_NODE" };
            string[] value    = { txtCode.Text, txtName.Text, txtUnit.Text, getType(), txtDscrp.Text, Convert.ToInt16(rdValid.Checked).ToString(), ((MSYS.Data.SysUser)Session["User"]).id, System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), listEquip.SelectedValue, txtSetTag.Text, txtValueTag.Text, listApt.SelectedValue, listPathnode.SelectedValue };

            string log_message;
            if (opt.MergeInto(seg, value, 1, "HT_PUB_TECH_PARA") == "Success")
            {
                log_message = "保存参数点成功";
                tvHtml      = InitTree();
                string[] procseg    = { };
                object[] procvalues = { };
                opt.ExecProcedures("Create_Online_month_Report", procseg, procvalues);
                if (ckQuaAnalyze.Checked && oldepath != listPathnode.SelectedValue)
                {
                    DataSet points = opt.CreateDataSetOra("select distinct path_code,path_name from ht_pub_para_weight t ");
                    if (points != null && points.Tables[0].Rows.Count > 0)
                    {
                        foreach (DataRow row in points.Tables[0].Rows)
                        {
                            if (listPathnode.SelectedValue == "")
                            {
                                opt.UpDateOra("insert into ht_pub_para_weight(para_code,path_code,weight,path_name)values ('" + txtCode.Text + "','" + row["path_code"].ToString() + "','0.2','" + row["path_name"].ToString() + "')");
                            }
                            else
                            {
                                DataSet paras = opt.CreateDataSetOra("select  r.para_code,t.pathcode from ht_pub_path_prod t  left join ht_pub_path_node s on s.is_del = '0' and  s.section_code = t.section_code and substr(t.section_path,s.orders,1) = '0' left join ht_pub_tech_para r on r.path_node = s.id and r.is_del = '0' and r.para_type like '______1%' where t.pathcode = '" + row["path_code"].ToString() + "' and t.is_del = '0' and r.para_code = '" + txtCode.Text + "'");
                                if (paras != null && paras.Tables[0].Rows.Count > 0)
                                {
                                    opt.UpDateOra("delete from ht_pub_para_weight where para_code = '" + txtCode.Text + "' and path_code = '" + row["path_code"].ToString() + "'");
                                }
                            }
                        }
                    }
                }
                // opt.UpDateOra("delete from ht_pub_para_weight where PATH_CODE = '" + listPathAll.SelectedValue + "'");
                // opt.UpDateOra("insert into ht_pub_para_weight ( select  r.para_code,t.pathcode,'0',0.2,'test1' from ht_pub_path_prod t  left join ht_pub_path_node s on s.is_del = '0' and  s.section_code = t.section_code and substr(t.section_path,s.orders,1) = '1' left join ht_pub_tech_para r on r.path_node = s.id and r.is_del = '0' and r.para_type like '______1%' where t.pathcode = '" + listPathAll.SelectedValue + "' and t.is_del = '0' and r.para_code is not null union select r.para_code,'" + listPathAll.SelectedValue + "','0',0.2,'test1' from ht_pub_tech_para r where r.para_type like '______1%' and r.path_node is null and r.is_del = '0')");
            }
            else
            {
                log_message = "保存参数点失败";
            }
            log_message += "--数据详情:" + string.Join(",", value);
            ScriptManager.RegisterStartupScript(UpdatePanel4, this.Page.GetType(), "sucess", "initTree();alert('" + log_message + "');", true);
            InsertTlog(log_message);
        }
        else
        {
            ScriptManager.RegisterStartupScript(UpdatePanel4, this.Page.GetType(), "message", "alert('请确认工艺参数所属工艺段是否正确')", true);
        }
    }
Exemple #5
0
 protected void btnGrid1DelSel_Click(object sender, EventArgs e)//删除选中记录
 {
     try
     {
         //    createGridView();
         for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
         {
             if (((CheckBox)GridView1.Rows[i].FindControl("ck")).Checked)
             {
                 string projcode         = GridView1.DataKeys[i].Value.ToString();
                 string query            = "delete from  ht_qlt_inspect_proj   where INSPECT_CODE = '" + projcode + "'";
                 MSYS.DAL.DbOperator opt = new MSYS.DAL.DbOperator();
                 string log_message      = opt.UpDateOra(query) == "Success" ? "删除工艺检查项目成功" : "删除工艺检查项目失败";
                 if (log_message == "删除工艺检查项目成功")
                 {
                     string[] procseg    = { };
                     object[] procvalues = { };
                     if (GridView1.Rows[i].Cells[2].Text == "感观评测")
                     {
                         opt.ExecProcedures("Create_Sensor_Report", procseg, procvalues);
                     }
                     else if (GridView1.Rows[i].Cells[1].Text == "成品检验" && GridView1.Rows[i].Cells[2].Text != "感观评测")
                     {
                         opt.ExecProcedures("Create_phychem_Report", procseg, procvalues);
                     }
                     else
                     {
                         opt.ExecProcedures("Create_process_Report", procseg, procvalues);
                     }
                 }
                 log_message += "--标识:" + projcode;
                 InsertTlog(log_message);
             }
         }
         bindGrid();
     }
     catch (Exception ee)
     {
         Response.Write(ee.Message);
     }
 }
Exemple #6
0
 protected void btnGrid2DelSel_Click(object sender, EventArgs e)//删除选中记录
 {
     for (int i = 0; i <= GridView2.Rows.Count - 1; i++)
     {
         if (((CheckBox)GridView2.Rows[i].FindControl("ck")).Checked)
         {
             string projcode         = GridView2.DataKeys[i].Value.ToString();
             string query            = "delete from  HT_QLT_SENSOR_STDD   where INSPECT_CODE = '" + projcode + "'";
             MSYS.DAL.DbOperator opt = new MSYS.DAL.DbOperator();
             string log_message      = opt.UpDateOra(query) == "Success" ? "删除工艺检查标准成功" : "删除工艺检查标准失败";
             if (log_message == "删除工艺检查标准成功")
             {
                 string[] procseg    = { };
                 object[] procvalues = { };
                 opt.ExecProcedures("Create_Sensor_Report", procseg, procvalues);
             }
             log_message += "--标识:" + projcode;
             InsertTlog(log_message);
         }
     }
     bindGrid2();
 }
Exemple #7
0
    protected void btnDel_Click(object sender, EventArgs e)
    {
        MSYS.DAL.DbOperator opt = new MSYS.DAL.DbOperator();
        string query            = "delete from HT_PUB_TECH_PARA  where PARA_CODE =  '" + txtCode.Text + "'";

        string log_message;

        if (opt.UpDateOra(query) == "Success")
        {
            log_message = "删除工艺参数点成功";
            tvHtml      = InitTree();
            string[] procseg    = { };
            object[] procvalues = { };
            opt.ExecProcedures("Create_Online_month_Report", procseg, procvalues);
            ScriptManager.RegisterStartupScript(UpdatePanel4, this.Page.GetType(), "sucess", "initTree();alert('删除成功');", true);
        }
        else
        {
            log_message = "删除工艺参数点失败";
        }
        log_message += ",工艺参数点ID:" + txtCode.Text;
        InsertTlog(log_message);
    }
Exemple #8
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)
        {
            string[] seg = { "INSPECT_CODE", "MINUS_SCORE", "REMARK", "CREATE_ID", "CREATE_TIME" };

            string[] value = { ((DropDownList)row.FindControl("listInspect")).SelectedValue, ((TextBox)row.FindControl("txtScore")).Text, ((TextBox)row.FindControl("txtRemark")).Text, ((MSYS.Data.SysUser)Session["User"]).id, System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") };
            commandlist.Add(opt.getMergeStr(seg, value, 1, "HT_QLT_SENSOR_STDD"));
        }
        string log_message = opt.TransactionCommand(commandlist) == "Success" ? "保存感观评测标准成功" : "保存感观评测标准失败";

        if (log_message == "保存感观评测标准成功")
        {
            string[] procseg    = { };
            object[] procvalues = { };
            opt.ExecProcedures("Create_Sensor_Report", procseg, procvalues);
        }
        InsertTlog(log_message);
        bindGrid2();
        ScriptManager.RegisterStartupScript(UpdatePanel2, this.Page.GetType(), "success", "alert('" + log_message + "')", true);
    }
Exemple #9
0
        //在服务器中找到报表模板,从数据库中选择数据,将数据写入模板中,把该文件保存在服务器的C://temp目录下;客户端再下载该文件,就能在客户端进行浏览
        public string CreateExcel(string filename, string brand, string startDate, string endDate, string team, string style, string month, DateTime date, bool merge)
        {
            MSYS.Common.ExcelExport openXMLExcel = null;
            try
            {
                MSYS.DAL.DbOperator opt = new MSYS.DAL.DbOperator();
                string bookid           = opt.GetSegValue("select F_ID from ht_sys_excel_book where F_NAME = '" + filename + "'", "F_ID");
                string booktype         = opt.GetSegValue("select F_TYPE from ht_sys_excel_book where F_NAME = '" + filename + "'", "F_TYPE");

                string basedir       = System.AppDomain.CurrentDomain.BaseDirectory.ToString();
                string strFolderPath = basedir + @"\TEMP";
                if (!System.IO.Directory.Exists(strFolderPath))
                {
                    // 目录不存在,建立目录
                    System.IO.Directory.CreateDirectory(strFolderPath);
                }

                DirectoryInfo dyInfo = new DirectoryInfo(strFolderPath);
                //获取文件夹下所有的文件
                foreach (FileInfo feInfo in dyInfo.GetFiles())
                {
                    //判断文件日期是否小于今天,是则删除
                    if (feInfo.CreationTime < DateTime.Now.AddMinutes(-2))
                    {
                        feInfo.Delete();
                    }
                }
                foreach (DirectoryInfo dir in dyInfo.GetDirectories())
                {
                    if (dir.CreationTime < DateTime.Now.AddMinutes(-2))
                    {
                        dir.Delete(true);
                    }
                }
                //导出文件模板所在位置
                String sourcePath = basedir + @"templates\" + booktype + @"\" + filename + ".xls";

                String filepath = basedir + @"TEMP\" + filename + date.ToString("HHmmss") + style;
                //bool isrewrite = true; // true=覆盖已存在的同名文件,false则反之
                //System.IO.File.Copy(sourcePath, filepath, isrewrite);
                string  query = "select * from ht_sys_excel_seg where F_BOOK_ID = '" + bookid + "' order by  F_DES";
                DataSet data  = opt.CreateDataSetOra(query);

                //申明一个ExcelSaveAs对象,该对象完成将数据写入Excel的操作
                openXMLExcel = new MSYS.Common.ExcelExport(sourcePath, false);
                if (data.Tables[0].Select().GetLength(0) > 0)
                {
                    DataRow[] rows = data.Tables[0].Select();

                    foreach (DataRow row in rows)
                    {
                        string sqlstr = row["F_SQL"].ToString();
                        //设定选择的数据的日期及牌号等信息
                        if (brand != "")
                        {
                            sqlstr = sqlstr.Replace("$brand$", brand);
                        }
                        if (startDate != "")
                        {
                            sqlstr = sqlstr.Replace("$startDate$", startDate);
                        }
                        if (endDate != "")
                        {
                            sqlstr = sqlstr.Replace("$endDate$", endDate);
                        }
                        if (team != "")
                        {
                            sqlstr = sqlstr.Replace("$team$", team);
                        }
                        if (month != "")
                        {
                            sqlstr = sqlstr.Replace("$month$", month);
                        }
                        if (sqlstr != "")
                        {
                            //将选择的数据写入Excel

                            if (sqlstr.Length > 4 && sqlstr.Substring(0, 3) == "STR")
                            {
                                sqlstr = sqlstr.Substring(4);
                                Response.Write(openXMLExcel.SetCurrentSheet(Convert.ToInt32(row["F_SHEETINDEX"].ToString())));
                                Response.Write(openXMLExcel.WriteData(Convert.ToInt32(row["F_DESX"].ToString()), getColumn(row["F_DESY"].ToString()) + 1, sqlstr));
                            }
                            if (sqlstr.Length > 5 && sqlstr.Substring(0, 4) == "Proc")
                            {
                                int           pos       = sqlstr.IndexOf('@');
                                int           pos2      = sqlstr.IndexOf('#');
                                string        proc      = sqlstr.Substring(5, pos - 5);
                                int           paracount = Regex.Matches(sqlstr, @"@").Count;
                                List <string> seglist   = new List <string>();
                                List <string> paralist  = new List <string>();
                                for (int i = 0; i < paracount; i++)
                                {
                                    seglist.Add(sqlstr.Substring(pos + 1, pos2 - pos - 1));
                                    pos = sqlstr.IndexOf('@', pos2);
                                    if (pos > 0)
                                    {
                                        paralist.Add(sqlstr.Substring(pos2 + 1, pos - pos2 - 1));
                                        pos2 = sqlstr.IndexOf('#', pos);
                                    }
                                    else
                                    {
                                        paralist.Add(sqlstr.Substring(pos2 + 1));
                                    }
                                }
                                opt.ExecProcedures(proc, seglist.ToArray(), paralist.ToArray());
                            }
                            if (sqlstr.Length > 20 && sqlstr.Substring(0, 3) == "SQL")
                            {
                                sqlstr = sqlstr.Substring(4).Trim();
                                System.Diagnostics.Debug.WriteLine(sqlstr);
                                bool hasCaption = false;
                                if (sqlstr.Substring(0, 1) == "$")
                                {
                                    hasCaption = true;
                                    sqlstr     = sqlstr.Substring(1);
                                }
                                DataSet set = new DataSet();
                                if (sqlstr.Substring(0, 5) == "SHIFT")
                                {
                                    sqlstr = sqlstr.Substring(6).Trim();
                                    set    = opt.ShiftTable(sqlstr);
                                }
                                else
                                {
                                    set = opt.CreateDataSetOra(sqlstr);
                                }
                                if (set != null)
                                {
                                    DataTable dt = set.Tables[0];

                                    openXMLExcel.SetCurrentSheet(Convert.ToInt32(row["F_SHEETINDEX"].ToString()));
                                    if (merge)
                                    {
                                        if (hasCaption)
                                        {
                                            openXMLExcel.WriteDataRerangeWithCaption(Convert.ToInt32(row["F_DESX"].ToString()), getColumn(row["F_DESY"].ToString()) + 1, dt);
                                        }
                                        else
                                        {
                                            openXMLExcel.WriteDataRerange(Convert.ToInt32(row["F_DESX"].ToString()), getColumn(row["F_DESY"].ToString()) + 1, dt);
                                        }
                                    }
                                    else
                                    {
                                        if (hasCaption)
                                        {
                                            openXMLExcel.WriteDataIntoWorksheetWithCaption(Convert.ToInt32(row["F_DESX"].ToString()), getColumn(row["F_DESY"].ToString()) + 1, dt);
                                        }
                                        else
                                        {
                                            openXMLExcel.WriteDataIntoWorksheet(Convert.ToInt32(row["F_DESX"].ToString()), getColumn(row["F_DESY"].ToString()) + 1, dt);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                ///客户端再下载该文件,在客户端进行浏览
                FileInfo fi = new FileInfo(filepath);
                if (fi.Exists)     //判断文件是否已经存在,如果存在就删除!
                {
                    fi.Delete();
                }
                if (style == ".xlsx" || style == ".xls")
                {
                    openXMLExcel.SaveAs(filepath);
                }
                else
                {
                    openXMLExcel.SaveAsHtm(filepath);
                    System.Diagnostics.Debug.WriteLine("路径");
                    System.Diagnostics.Debug.WriteLine(filepath);
                }
                openXMLExcel.Dispose();
                openXMLExcel = null;
                KillProcess("EXCEL.EXE");
                return("Success");
            }
            catch (Exception e)
            {
                if (openXMLExcel != null)
                {
                    openXMLExcel.Dispose();
                }
                return(e.Message);
            }
            finally
            {
            }
        }