コード例 #1
0
    /// <summary>
    /// 查看检测明细
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void GridView1_RowDeleting1(object sender, GridViewDeleteEventArgs e)
    {
        string Id = this.grid1.DataKeys[e.RowIndex].Values["id"].ToString();//标志

        BProductCheckDetailBB checkDetailBB = new BProductCheckDetailBB();
        DataSet ds = new DataSet();

        try
        {
            ds = checkDetailBB.GetVList(" checkDetailId=" + Id);
            this.grid.DataSource = ds.Tables[0];
            this.grid.DataBind();
            //赋值记录条数、页面总数
        }
        finally
        {
            checkDetailBB.Dispose();
        }

        this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "showFloat();", true);
    }
コード例 #2
0
    /// <summary>
    /// 导入excel  检测明细
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnUp_Click(object sender, EventArgs e)
    {
        if (ddlGun.SelectedValue != "0")
        {

            if (this.File1.Value == "")
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"请选择要导入的文件。\");", true);
                return;

            }
            string strFileName = this.SaveFile(this.File1.PostedFile);
            if (strFileName != "")
            {
                string readSheetName = strFileName.Remove(0, strFileName.LastIndexOf("\\") + 1);//只是获取文件的名称
                string readSheetName2 = readSheetName.Remove(readSheetName.LastIndexOf("."));
                DataSet ds = HS.Function.CommFunction.ReadExcel(strFileName, readSheetName2);
                if (ds == null || ds.Tables.Count == 0)
                {
                    this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"读取数据源文件时出错,请重试。\");", true);
                    return;
                }

                if (ds.Tables[0].Columns.Count != 28)//导入的excel的 列数是否合格
                {

                    this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"读取的Excel列数不正确。\");", true);
                    return;
                }

                if (ds.Tables[0].Columns.Contains("Date") && ds.Tables[0].Columns.Contains("Reading") && ds.Tables[0].Columns.Contains("Invoice No#") && ds.Tables[0].Columns.Contains("Code No#")
                   && ds.Tables[0].Columns.Contains("Size") && ds.Tables[0].Columns.Contains("Match1") && ds.Tables[0].Columns.Contains("Cr") && ds.Tables[0].Columns.Contains("Cr +/-")
                  && ds.Tables[0].Columns.Contains("Ni") && ds.Tables[0].Columns.Contains("Ni +/-") && ds.Tables[0].Columns.Contains("Mo") && ds.Tables[0].Columns.Contains("Mo +/-")
                    && ds.Tables[0].Columns.Contains("Cu") && ds.Tables[0].Columns.Contains("Cu +/-") && ds.Tables[0].Columns.Contains("Mn") && ds.Tables[0].Columns.Contains("Mn +/-")
                    && ds.Tables[0].Columns.Contains("Fe") && ds.Tables[0].Columns.Contains("Fe +/-") && ds.Tables[0].Columns.Contains("Co") && ds.Tables[0].Columns.Contains("Co +/-")
                    && ds.Tables[0].Columns.Contains("Nb") && ds.Tables[0].Columns.Contains("Nb +/-") && ds.Tables[0].Columns.Contains("Zr") && ds.Tables[0].Columns.Contains("Zr +/-")
                    && ds.Tables[0].Columns.Contains("Ti") && ds.Tables[0].Columns.Contains("Ti +/-"))
                {

                }
                else
                {
                    this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"读取的Excel列不正确。\");", true);
                    return;
                }
                ds.Tables[0].Columns.Add("error");
                ds.Tables[0].Columns.Add("id");
                ds.Tables[0].Columns.Add("gunid");
                ds.Tables[0].Columns.Add("errormsg");

                try
                {
                    string maxdt = ds.Tables[0].Compute("max(Date)", "").ToString();
                    string mindt = ds.Tables[0].Compute("min(Date)", "").ToString();

                    DataSet dtSource = new DataSet();
                    BProductCheckDetailBB productCheckDetailBB = new BProductCheckDetailBB();
                    StringBuilder strErrorInfo = new StringBuilder();

                    bool isSuccess = true;

                    dtSource = productCheckDetailBB.GetList("checkDt between '" + Convert.ToDateTime(mindt) + "' and '" + Convert.ToDateTime(maxdt) + "'");

                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        string ss = " checkDt='" + dr["Date"] + "'  and  checkGunId=" + ddlGun.SelectedValue + "  and checkGunIndex=" + dr["Reading"];

                        DataRow[] drs = dtSource.Tables[0].Select(" checkDt='" + dr["Date"] + "'  and  checkGunId=" + ddlGun.SelectedValue + "  and checkGunIndex=" + dr["Reading"]);

                        int demo = 0;
                        if (drs.Length <= 0)
                        {
                            // dr["id"] = "0";

                            dr["error"] = Convert.ToInt32(dr["error"] == DBNull.Value ? "0" : dr["error"]) + 1;
                            dr["errormsg"] = dr["errormsg"].ToString() + ",数据不存在";

                            // isSuccess = false;
                            demo = 1;
                        }
                        else
                        {
                            dr["id"] = drs[0]["id"];
                        }

                        DateTime dtnow = DateTime.Now;
                        if (!DateTime.TryParse(dr["Date"].ToString(), out dtnow))
                        {
                            dr["error"] = Convert.ToInt32(dr["error"] == DBNull.Value ? "0" : dr["error"]) + 1;
                            dr["errormsg"] = dr["errormsg"].ToString() + ",检测日期不正确";
                            isSuccess = false;
                        }
                        int gunid = 0;
                        if (!int.TryParse(dr["Reading"].ToString(), out gunid))
                        {
                            dr["error"] = Convert.ToInt32(dr["error"] == DBNull.Value ? "0" : dr["error"]) + 1;
                            dr["errormsg"] = dr["errormsg"].ToString() + ",检测枪号不正确";
                            isSuccess = false;
                        }
                        dr["gunid"] = this.ddlGun.SelectedValue;

                        if (demo == 0)
                        {
                            BProductCheckDetailData model = new BProductCheckDetailData();
                            model.id = Convert.ToInt32(dr["id"]);
                            model.checkGunId = Convert.ToInt32(ddlGun.SelectedValue);
                            model.checkGunIndex = gunid;
                            model.checkDt = dtnow.ToString();
                            model.Cr = dr["Cr"].ToString();
                            model.CrAdd = dr["Cr +/-"].ToString();
                            model.Ni = dr["Ni"].ToString();
                            model.NiAdd = dr["Ni +/-"].ToString();
                            model.Mo = dr["Mo"].ToString();
                            model.MoAdd = dr["Mo +/-"].ToString();
                            model.Cu = dr["Cu"].ToString();
                            model.CuAdd = dr["Cu +/-"].ToString();
                            model.Mn = dr["Mn"].ToString();
                            model.MnAdd = dr["Mn +/-"].ToString();
                            model.Fe = dr["Fe"].ToString();
                            model.FeAdd = dr["Fe +/-"].ToString();
                            model.Co = dr["Co"].ToString();
                            model.CoAdd = dr["Co +/-"].ToString();
                            model.Nb = dr["Nb"].ToString();
                            model.NbAdd = dr["Nb +/-"].ToString();
                            model.Zr = dr["Zr"].ToString();
                            model.ZrAdd = dr["Zr +/-"].ToString();
                            model.Ti = dr["Ti"].ToString();
                            model.TiAdd = dr["Ti +/-"].ToString();

                            this.Lists.Add(model);
                        }
                    }

                    if (!isSuccess)
                    {
                        this.Lists.Clear();
                    }
                }
                catch
                {
                    this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"导入数据出错误!\");", true);
                    return;
                }

                //try
                //{
                //    bool isSuccessA = plateformServicesBC.ImportRecord(modelList, this.currentUser.nowDepartId, this.currentUser.empId);
                //    if (isAllSuccess && isSuccessA)
                //    {
                //        this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"平台服务商导入成功!\");", true);
                //    }

                //    if (!isAllSuccess)
                //    {
                //        this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"" + strErrorInfo.ToString() + "!\");", true);
                //    }
                //}
                //catch (Exception ex)
                //{
                //    this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"平台服务商导入出错,请重试!\");", true);
                //}
                //finally
                //{
                //    tradeOGBB.Dispose();
                //    productSortBB.Dispose();
                //    custBB.Dispose();
                //    plateformServicesBC.Dispose();
                //}

                DTResult = ds.Tables[0];
                DSFlash();

            }
        }
        else
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"请选择扫描枪!\");", true);
        }
    }
コード例 #3
0
    public DataTable GetProductCheckDetail(int checkDetailId)
    {
        BProductCheckDetailBB productCheckDetailBB = new BProductCheckDetailBB();

        try
        {
            DataTable dt = new DataTable();

            dt = productCheckDetailBB.GetVList("checkDetailId=" + checkDetailId.ToString()).Tables[0];
            return dt;
        }
        finally
        {
            productCheckDetailBB.Dispose();
        }
    }
コード例 #4
0
    /// <summary>
    /// 删除
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnDel_Click(object sender, EventArgs e)
    {
        bool retChecked = false;
        BProductCheckDetailBB productCheckDetailBB = new BProductCheckDetailBB();
        try
        {
            //获取选中的数据Id
            foreach (GridViewRow gvrow in this.grid.Rows)
            {
                CheckBox chkId = (CheckBox)gvrow.FindControl("chkId");
                if (chkId.Checked == true)
                {
                    retChecked = true;
                    int id = int.Parse(chkId.ValidationGroup);
                    productCheckDetailBB.DeleteRecord(id);
                }
            }
        }
        catch (Exception ex)
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true);
            return;
        }
        finally
        {
            productCheckDetailBB.Dispose();
        }

        if (retChecked)
        {
            this.BindGrid();
        }
    }
コード例 #5
0
    public bool DeleteProductCheckDetail(int id)
    {
        BProductCheckDetailBB productCheckDetailBB = new BProductCheckDetailBB();

        try
        {
            return productCheckDetailBB.DeleteRecord(id);
        }
        finally
        {
            productCheckDetailBB.Dispose();
        }
    }