コード例 #1
0
        private void btn_Sure_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(btn_GZ.Text.Trim()))
                {
                    MessageBox.Show("请填写钢种!");
                    return;
                }

                if (string.IsNullOrEmpty(txt_BZ.Text.Trim()))
                {
                    MessageBox.Show("请填写标准!");
                    return;
                }

                Mod_TQB_SAMP_MODLE_JSZX model = new Mod_TQB_SAMP_MODLE_JSZX();
                model.C_STL_GRD  = btn_GZ.Text.Trim();
                model.C_STD_CODE = txt_BZ.Text.Trim();
                model.C_SPEC_MIN = txt_Spec_Min.Text.Trim();
                model.C_SPEC_MAX = txt_Spec_Max.Text.Trim();
                model.C_EMP_ID   = RV.UI.UserInfo.userID;

                if (bllTqbSampModleJszx.Add(model))
                {
                    MessageBox.Show("添加成功!");
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #2
0
        private void btn_Bz_Click(object sender, EventArgs e)
        {
            try
            {
                DataTable dt     = OpenExcelFile(this.txtUrl.Text, "Sheet1");
                string    strLog = "";

                Int64 i_id = 2019041100000;

                if (dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        DataTable dtMain = bllMain.GetList_ID(dt.Rows[i]["文件号"].ToString().Trim(), dt.Rows[i]["牌号"].ToString().Trim()).Tables[0];

                        if (dtMain.Rows.Count > 0)
                        {
                            i_id++;

                            Mod_TQB_SAMP_MODLE_JSZX modSam = new Mod_TQB_SAMP_MODLE_JSZX();
                            modSam.C_ID       = i_id.ToString();
                            modSam.C_STD_CODE = dt.Rows[i]["文件号"].ToString().Trim();
                            modSam.C_STL_GRD  = dt.Rows[i]["牌号"].ToString().Trim();
                            //modSam.C_SPEC_MIN = dt.Rows[i]["规格"].ToString().Trim();
                            //modSam.C_SPEC_MAX = dt.Rows[i]["规格最大"].ToString().Trim();

                            bllTqbSampModleJszx.Add(modSam);

                            for (int kk = 3; kk < dt.Columns.Count; kk++)
                            {
                                string strID = bllTqbSam.GetSampId(dt.Columns[kk].ColumnName, "技术中心");

                                if (!string.IsNullOrEmpty(dt.Rows[i][kk].ToString().Trim()))
                                {
                                    Mod_TQB_SAMP_ITEM_MODLE_JSZX modItem = new Mod_TQB_SAMP_ITEM_MODLE_JSZX();
                                    modItem.C_SAMP_MODLE_ID = modSam.C_ID;
                                    modItem.C_SAMPLES_ID    = strID;
                                    modItem.C_SAM_NUM       = dt.Rows[i][kk].ToString().Trim();
                                    modItem.C_SAMPLES_NAME  = dt.Columns[kk].ColumnName;

                                    bllTqbSampItemModleJszx.Add(modItem);
                                }
                            }
                        }
                        else
                        {
                            strLog = strLog + "添加失败:" + dt.Rows[i]["文件号"].ToString() + "   " + dt.Rows[i]["牌号"].ToString() + ";";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Mod_TQB_SAMP_MODLE_JSZX model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update TQB_SAMP_MODLE_JSZX set ");
            strSql.Append("C_STD_CODE=:C_STD_CODE,");
            strSql.Append("C_STL_GRD=:C_STL_GRD,");
            strSql.Append("C_SPEC_MIN=:C_SPEC_MIN,");
            strSql.Append("C_SPEC_MAX=:C_SPEC_MAX,");
            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_CODE", OracleDbType.Varchar2, 100),
                new OracleParameter(":C_STL_GRD",  OracleDbType.Varchar2, 100),
                new OracleParameter(":C_SPEC_MIN", OracleDbType.Varchar2, 100),
                new OracleParameter(":C_SPEC_MAX", OracleDbType.Varchar2, 100),
                new OracleParameter(":N_STATUS",   OracleDbType.Decimal,    1),
                new OracleParameter(":C_REMARK",   OracleDbType.Varchar2, 100),
                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_CODE;
            parameters[1].Value = model.C_STL_GRD;
            parameters[2].Value = model.C_SPEC_MIN;
            parameters[3].Value = model.C_SPEC_MAX;
            parameters[4].Value = model.N_STATUS;
            parameters[5].Value = model.C_REMARK;
            parameters[6].Value = model.C_EMP_ID;
            parameters[7].Value = model.D_MOD_DT;
            parameters[8].Value = model.C_ID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Mod_TQB_SAMP_MODLE_JSZX DataRowToModel(DataRow row)
        {
            Mod_TQB_SAMP_MODLE_JSZX model = new Mod_TQB_SAMP_MODLE_JSZX();

            if (row != null)
            {
                if (row["C_ID"] != null)
                {
                    model.C_ID = row["C_ID"].ToString();
                }
                if (row["C_STD_CODE"] != null)
                {
                    model.C_STD_CODE = row["C_STD_CODE"].ToString();
                }
                if (row["C_STL_GRD"] != null)
                {
                    model.C_STL_GRD = row["C_STL_GRD"].ToString();
                }
                if (row["C_SPEC_MIN"] != null)
                {
                    model.C_SPEC_MIN = row["C_SPEC_MIN"].ToString();
                }
                if (row["C_SPEC_MAX"] != null)
                {
                    model.C_SPEC_MAX = row["C_SPEC_MAX"].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);
        }
コード例 #5
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add_Trans(Mod_TQB_SAMP_MODLE_JSZX model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into TQB_SAMP_MODLE_JSZX(");
            strSql.Append("C_ID,C_STD_CODE,C_STL_GRD,C_SPEC_MIN,C_SPEC_MAX,N_STATUS,C_REMARK,C_EMP_ID,D_MOD_DT)");
            strSql.Append(" values (");
            strSql.Append(":C_ID,:C_STD_CODE,:C_STL_GRD,:C_SPEC_MIN,:C_SPEC_MAX,:N_STATUS,:C_REMARK,:C_EMP_ID,:D_MOD_DT)");
            OracleParameter[] parameters =
            {
                new OracleParameter(":C_ID",       OracleDbType.Varchar2, 100),
                new OracleParameter(":C_STD_CODE", OracleDbType.Varchar2, 100),
                new OracleParameter(":C_STL_GRD",  OracleDbType.Varchar2, 100),
                new OracleParameter(":C_SPEC_MIN", OracleDbType.Varchar2, 100),
                new OracleParameter(":C_SPEC_MAX", OracleDbType.Varchar2, 100),
                new OracleParameter(":N_STATUS",   OracleDbType.Decimal,    1),
                new OracleParameter(":C_REMARK",   OracleDbType.Varchar2, 100),
                new OracleParameter(":C_EMP_ID",   OracleDbType.Varchar2, 100),
                new OracleParameter(":D_MOD_DT",   OracleDbType.Date)
            };
            parameters[0].Value = model.C_ID;
            parameters[1].Value = model.C_STD_CODE;
            parameters[2].Value = model.C_STL_GRD;
            parameters[3].Value = model.C_SPEC_MIN;
            parameters[4].Value = model.C_SPEC_MAX;
            parameters[5].Value = model.N_STATUS;
            parameters[6].Value = model.C_REMARK;
            parameters[7].Value = model.C_EMP_ID;
            parameters[8].Value = model.D_MOD_DT;

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

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

            strSql.Append("select C_ID,C_STD_CODE,C_STL_GRD,C_SPEC_MIN,C_SPEC_MAX,N_STATUS,C_REMARK,C_EMP_ID,D_MOD_DT from TQB_SAMP_MODLE_JSZX ");
            strSql.Append(" where C_ID=:C_ID ");
            OracleParameter[] parameters =
            {
                new OracleParameter(":C_ID", OracleDbType.Varchar2, 100)
            };
            parameters[0].Value = C_ID;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
コード例 #7
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Mod_TQB_SAMP_MODLE_JSZX model)
 {
     return(dal.Update(model));
 }
コード例 #8
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(Mod_TQB_SAMP_MODLE_JSZX model)
 {
     return(dal.Add(model));
 }
コード例 #9
0
        /// <summary>
        /// 保存模板信息
        /// </summary>
        /// <returns></returns>
        public string Save_Modle(DataTable dt)
        {
            try
            {
                string result = "1";

                TransactionHelper.BeginTransaction();

                string   strUserID = RV.UI.UserInfo.userID;
                DateTime time      = RV.UI.ServerTime.timeNow();

                Dal_TQB_SAMP_ITEM_MODLE_JSZX dalTqbItem     = new Dal_TQB_SAMP_ITEM_MODLE_JSZX();
                Dal_TQB_SAMPLING             dalTqbSampling = new Dal_TQB_SAMPLING();

                dalTqbItem.Update_Trans(dt.Rows[0]["执行标准"].ToString(), dt.Rows[0]["钢种"].ToString(), dt.Rows[0]["规格最小值"].ToString(), dt.Rows[0]["规格最大值"].ToString());

                if (!dal.update_Trans(dt.Rows[0]["执行标准"].ToString(), dt.Rows[0]["钢种"].ToString(), dt.Rows[0]["规格最小值"].ToString(), dt.Rows[0]["规格最大值"].ToString()))
                {
                    TransactionHelper.RollBack();
                    return("保存失败!");
                }

                for (int irow = 0; irow < dt.Rows.Count; irow++)
                {
                    Int64 i_ID = dal.Get_Max_ID_Trans();
                    i_ID++;
                    Mod_TQB_SAMP_MODLE_JSZX modMain = new Mod_TQB_SAMP_MODLE_JSZX();
                    modMain.C_ID       = i_ID.ToString();
                    modMain.C_STD_CODE = dt.Rows[irow]["执行标准"].ToString();
                    modMain.C_STL_GRD  = dt.Rows[irow]["钢种"].ToString();
                    modMain.C_SPEC_MIN = dt.Rows[irow]["规格最小值"].ToString();
                    modMain.C_SPEC_MAX = dt.Rows[irow]["规格最大值"].ToString();
                    modMain.C_EMP_ID   = strUserID;
                    modMain.D_MOD_DT   = time;

                    if (!dal.Add_Trans(modMain))
                    {
                        TransactionHelper.RollBack();
                        return("保存失败!");
                    }

                    for (int icol = 5; icol < dt.Columns.Count; icol++)
                    {
                        if (!string.IsNullOrEmpty(dt.Rows[irow][icol].ToString().Trim()))
                        {
                            Mod_TQB_SAMP_ITEM_MODLE_JSZX modItem = new Mod_TQB_SAMP_ITEM_MODLE_JSZX();

                            string SampId = dalTqbSampling.GetSampId(dt.Columns[icol].ColumnName, "技术中心");

                            modItem.C_SAMP_MODLE_ID = i_ID.ToString();
                            modItem.C_SAMPLES_ID    = SampId;
                            modItem.C_SAM_NUM       = dt.Rows[irow][icol].ToString();
                            modItem.C_EMP_ID        = strUserID;
                            modItem.D_MOD_DT        = time;
                            modItem.C_SAMPLES_NAME  = dt.Columns[icol].ColumnName;

                            if (!dalTqbItem.Add_Trans(modItem))
                            {
                                TransactionHelper.RollBack();
                                return("保存失败!");
                            }
                        }
                    }
                }

                TransactionHelper.Commit();
                return(result);
            }
            catch (Exception ex)
            {
                TransactionHelper.RollBack();
                return(ex.Message);
            }
        }