/// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Mod_TQB_STD_SAMPLING model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into TQB_STD_SAMPLING(");
            strSql.Append("C_STD_MAIN_ID,C_SAMPLING_ID,C_NUMBER,C_SAM_SPE,C_SAM_LEN,C_SAM_METHOD,C_SAM_NUM,C_RECHECK_NUM,C_NUM_UNIT,C_SAM_SECTION,C_TEST_UNIT,N_STATUS,C_REMARK,C_EMP_ID)");
            strSql.Append(" values (");
            strSql.Append(":C_STD_MAIN_ID,:C_SAMPLING_ID,:C_NUMBER,:C_SAM_SPE,:C_SAM_LEN,:C_SAM_METHOD,:C_SAM_NUM,:C_RECHECK_NUM,:C_NUM_UNIT,:C_SAM_SECTION,:C_TEST_UNIT,:N_STATUS,:C_REMARK,:C_EMP_ID)");
            OracleParameter[] parameters =
            {
                new OracleParameter(":C_STD_MAIN_ID", OracleDbType.Varchar2, 100),
                new OracleParameter(":C_SAMPLING_ID", OracleDbType.Varchar2, 100),
                new OracleParameter(":C_NUMBER",      OracleDbType.Varchar2, 100),
                new OracleParameter(":C_SAM_SPE",     OracleDbType.Varchar2, 100),
                new OracleParameter(":C_SAM_LEN",     OracleDbType.Varchar2, 100),
                new OracleParameter(":C_SAM_METHOD",  OracleDbType.Varchar2, 100),
                new OracleParameter(":C_SAM_NUM",     OracleDbType.Varchar2, 100),
                new OracleParameter(":C_RECHECK_NUM", OracleDbType.Varchar2, 100),
                new OracleParameter(":C_NUM_UNIT",    OracleDbType.Varchar2, 100),
                new OracleParameter(":C_SAM_SECTION", OracleDbType.Varchar2, 100),
                new OracleParameter(":C_TEST_UNIT",   OracleDbType.Varchar2, 500),
                new OracleParameter(":N_STATUS",      OracleDbType.Decimal,    1),
                new OracleParameter(":C_REMARK",      OracleDbType.Varchar2, 500),
                new OracleParameter(":C_EMP_ID",      OracleDbType.Varchar2, 100)
            };
            parameters[0].Value  = model.C_STD_MAIN_ID;
            parameters[1].Value  = model.C_SAMPLING_ID;
            parameters[2].Value  = model.C_NUMBER;
            parameters[3].Value  = model.C_SAM_SPE;
            parameters[4].Value  = model.C_SAM_LEN;
            parameters[5].Value  = model.C_SAM_METHOD;
            parameters[6].Value  = model.C_SAM_NUM;
            parameters[7].Value  = model.C_RECHECK_NUM;
            parameters[8].Value  = model.C_NUM_UNIT;
            parameters[9].Value  = model.C_SAM_SECTION;
            parameters[10].Value = model.C_TEST_UNIT;
            parameters[11].Value = model.N_STATUS;
            parameters[12].Value = model.C_REMARK;
            parameters[13].Value = model.C_EMP_ID;

            int rows = DbHelperOra.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Mod_TQB_STD_SAMPLING GetModel(string C_ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select C_ID,C_STD_MAIN_ID,C_SAMPLING_ID,C_NUMBER,C_SAM_SPE,C_SAM_LEN,C_SAM_METHOD,C_SAM_NUM,C_RECHECK_NUM,C_NUM_UNIT,C_SAM_SECTION,C_TEST_UNIT,N_STATUS,C_REMARK,C_EMP_ID,D_MOD_DT from TQB_STD_SAMPLING ");
            strSql.Append(" where C_ID=:C_ID ");
            OracleParameter[] parameters =
            {
                new OracleParameter(":C_ID", OracleDbType.Varchar2, 100)
            };
            parameters[0].Value = C_ID;

            Mod_TQB_STD_SAMPLING model = new Mod_TQB_STD_SAMPLING();
            DataSet ds = DbHelperOra.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Mod_TQB_STD_SAMPLING model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update TQB_STD_SAMPLING set ");
            strSql.Append("C_STD_MAIN_ID=:C_STD_MAIN_ID,");
            strSql.Append("C_SAMPLING_ID=:C_SAMPLING_ID,");
            strSql.Append("C_NUMBER=:C_NUMBER,");
            strSql.Append("C_SAM_SPE=:C_SAM_SPE,");
            strSql.Append("C_SAM_LEN=:C_SAM_LEN,");
            strSql.Append("C_SAM_METHOD=:C_SAM_METHOD,");
            strSql.Append("C_SAM_NUM=:C_SAM_NUM,");
            strSql.Append("C_RECHECK_NUM=:C_RECHECK_NUM,");
            strSql.Append("C_NUM_UNIT=:C_NUM_UNIT,");
            strSql.Append("C_SAM_SECTION=:C_SAM_SECTION,");
            strSql.Append("C_TEST_UNIT=:C_TEST_UNIT,");
            strSql.Append("N_STATUS=:N_STATUS,");
            strSql.Append("C_REMARK=:C_REMARK,");
            strSql.Append("C_EMP_ID=:C_EMP_ID,");
            strSql.Append("D_MOD_DT=:D_MOD_DT");
            strSql.Append(" where C_ID=:C_ID ");
            OracleParameter[] parameters =
            {
                new OracleParameter(":C_STD_MAIN_ID", OracleDbType.Varchar2, 100),
                new OracleParameter(":C_SAMPLING_ID", OracleDbType.Varchar2, 100),
                new OracleParameter(":C_NUMBER",      OracleDbType.Varchar2, 100),
                new OracleParameter(":C_SAM_SPE",     OracleDbType.Varchar2, 100),
                new OracleParameter(":C_SAM_LEN",     OracleDbType.Varchar2, 100),
                new OracleParameter(":C_SAM_METHOD",  OracleDbType.Varchar2, 100),
                new OracleParameter(":C_SAM_NUM",     OracleDbType.Varchar2, 100),
                new OracleParameter(":C_RECHECK_NUM", OracleDbType.Varchar2, 100),
                new OracleParameter(":C_NUM_UNIT",    OracleDbType.Varchar2, 100),
                new OracleParameter(":C_SAM_SECTION", OracleDbType.Varchar2, 100),
                new OracleParameter(":C_TEST_UNIT",   OracleDbType.Varchar2, 500),
                new OracleParameter(":N_STATUS",      OracleDbType.Decimal,    1),
                new OracleParameter(":C_REMARK",      OracleDbType.Varchar2, 500),
                new OracleParameter(":C_EMP_ID",      OracleDbType.Varchar2, 100),
                new OracleParameter(":D_MOD_DT",      OracleDbType.Date),
                new OracleParameter(":C_ID",          OracleDbType.Varchar2, 100)
            };
            parameters[0].Value  = model.C_STD_MAIN_ID;
            parameters[1].Value  = model.C_SAMPLING_ID;
            parameters[2].Value  = model.C_NUMBER;
            parameters[3].Value  = model.C_SAM_SPE;
            parameters[4].Value  = model.C_SAM_LEN;
            parameters[5].Value  = model.C_SAM_METHOD;
            parameters[6].Value  = model.C_SAM_NUM;
            parameters[7].Value  = model.C_RECHECK_NUM;
            parameters[8].Value  = model.C_NUM_UNIT;
            parameters[9].Value  = model.C_SAM_SECTION;
            parameters[10].Value = model.C_TEST_UNIT;
            parameters[11].Value = model.N_STATUS;
            parameters[12].Value = model.C_REMARK;
            parameters[13].Value = model.C_EMP_ID;
            parameters[14].Value = model.D_MOD_DT;
            parameters[15].Value = model.C_ID;

            int rows = DbHelperOra.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Mod_TQB_STD_SAMPLING DataRowToModel(DataRow row)
        {
            Mod_TQB_STD_SAMPLING model = new Mod_TQB_STD_SAMPLING();

            if (row != null)
            {
                if (row["C_ID"] != null)
                {
                    model.C_ID = row["C_ID"].ToString();
                }
                if (row["C_STD_MAIN_ID"] != null)
                {
                    model.C_STD_MAIN_ID = row["C_STD_MAIN_ID"].ToString();
                }
                if (row["C_SAMPLING_ID"] != null)
                {
                    model.C_SAMPLING_ID = row["C_SAMPLING_ID"].ToString();
                }
                if (row["C_NUMBER"] != null)
                {
                    model.C_NUMBER = row["C_NUMBER"].ToString();
                }
                if (row["C_SAM_SPE"] != null)
                {
                    model.C_SAM_SPE = row["C_SAM_SPE"].ToString();
                }
                if (row["C_SAM_LEN"] != null)
                {
                    model.C_SAM_LEN = row["C_SAM_LEN"].ToString();
                }
                if (row["C_SAM_METHOD"] != null)
                {
                    model.C_SAM_METHOD = row["C_SAM_METHOD"].ToString();
                }
                if (row["C_SAM_NUM"] != null)
                {
                    model.C_SAM_NUM = row["C_SAM_NUM"].ToString();
                }
                if (row["C_RECHECK_NUM"] != null)
                {
                    model.C_RECHECK_NUM = row["C_RECHECK_NUM"].ToString();
                }
                if (row["C_NUM_UNIT"] != null)
                {
                    model.C_NUM_UNIT = row["C_NUM_UNIT"].ToString();
                }
                if (row["C_SAM_SECTION"] != null)
                {
                    model.C_SAM_SECTION = row["C_SAM_SECTION"].ToString();
                }
                if (row["C_TEST_UNIT"] != null)
                {
                    model.C_TEST_UNIT = row["C_TEST_UNIT"].ToString();
                }
                if (row["N_STATUS"] != null && row["N_STATUS"].ToString() != "")
                {
                    model.N_STATUS = decimal.Parse(row["N_STATUS"].ToString());
                }
                if (row["C_REMARK"] != null)
                {
                    model.C_REMARK = row["C_REMARK"].ToString();
                }
                if (row["C_EMP_ID"] != null)
                {
                    model.C_EMP_ID = row["C_EMP_ID"].ToString();
                }
                if (row["D_MOD_DT"] != null && row["D_MOD_DT"].ToString() != "")
                {
                    model.D_MOD_DT = DateTime.Parse(row["D_MOD_DT"].ToString());
                }
            }
            return(model);
        }
Beispiel #5
0
        /// <summary>
        /// 导入取样
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_QY_Click(object sender, EventArgs e)
        {
            DataTable dt = OpenExcelFile(this.txtUrl.Text, "执行标准取样标准信息");

            StringBuilder strLog = new StringBuilder();

            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    DataTable dtMain = bllMain.GetList_ID(dt.Rows[i]["协议号"].ToString(), dt.Rows[i]["钢种"].ToString()).Tables[0];

                    if (dtMain.Rows.Count > 0)
                    {
                        string C_Samp_Id = bllSampling.GetSampId(dt.Rows[i]["检验项目"].ToString(), "");

                        if (!string.IsNullOrEmpty(C_Samp_Id))
                        {
                            //continue;

                            try
                            {
                                Mod_TQB_STD_SAMPLING model = new Mod_TQB_STD_SAMPLING();
                                model.C_STD_MAIN_ID = dtMain.Rows[0]["C_ID"].ToString();
                                model.C_SAMPLING_ID = C_Samp_Id;

                                model.C_NUMBER      = dt.Rows[i]["序列号"].ToString();
                                model.C_SAM_SPE     = dt.Rows[i]["取样规格 直接/宽*厚"].ToString();
                                model.C_SAM_LEN     = dt.Rows[i]["取样长度"].ToString();
                                model.C_SAM_METHOD  = dt.Rows[i]["取样方法"].ToString();
                                model.C_SAM_NUM     = dt.Rows[i]["取样 数量"].ToString();
                                model.C_RECHECK_NUM = dt.Rows[i]["复验样 数量"].ToString();
                                model.C_NUM_UNIT    = dt.Rows[i]["数量 单位"].ToString();
                                model.C_SAM_SECTION = dt.Rows[i]["取样部位"].ToString();
                                model.C_TEST_UNIT   = dt.Rows[i]["试验方法"].ToString();
                                model.C_REMARK      = dt.Rows[i]["备注"].ToString();
                                model.C_EMP_ID      = "777";

                                bool res = bllStdSampling.Add(model);

                                rtxt_Log.Text = strLog.ToString();
                            }
                            catch
                            {
                                strLog.Append("添加失败:" + dt.Rows[i]["协议号"].ToString() + dt.Rows[i]["钢种"].ToString() + dt.Rows[i]["检验项目"].ToString() + "\n");
                            }
                        }
                        else
                        {
                            strLog.Append("添加失败:" + dt.Rows[i]["检验项目"].ToString() + "\n");
                        }
                    }
                }

                strLog.Append("导入完成!");

                rtxt_Log.Text = strLog.ToString();

                Common.UserLog.AddLog(strMenuName, this.Name, this.Text, "导入取样");//添加操作日志
            }
        }
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Mod_TQB_STD_SAMPLING model)
 {
     return(dal.Update(model));
 }
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(Mod_TQB_STD_SAMPLING model)
 {
     return(dal.Add(model));
 }