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

            strSql.Append("insert into TQC_PRESENT_SAMPLES_JSZX(");
            strSql.Append("C_BATCH_NO,C_TICK_NO,C_STL_GRD,C_SPEC,N_ENTRUST_TYPE,N_STATUS,C_REMARK,C_EMP_ID_SY,D_MOD_DT_SY,C_EMP_ID_JS,D_MOD_DT_JS,C_EMP_ID_ZY,D_MOD_DT_ZY,C_EQ_NAME,C_EQ_NUMBER,C_EQ_CODE,N_SAMPLES_NUM,D_MOD_DT)");
            strSql.Append(" values (");
            strSql.Append(":C_BATCH_NO,:C_TICK_NO,:C_STL_GRD,:C_SPEC,:N_ENTRUST_TYPE,:N_STATUS,:C_REMARK,:C_EMP_ID_SY,:D_MOD_DT_SY,:C_EMP_ID_JS,:D_MOD_DT_JS,:C_EMP_ID_ZY,:D_MOD_DT_ZY,:C_EQ_NAME,:C_EQ_NUMBER,:C_EQ_CODE,:N_SAMPLES_NUM,:D_MOD_DT)");
            OracleParameter[] parameters =
            {
                new OracleParameter(":C_BATCH_NO",     OracleDbType.Varchar2, 100),
                new OracleParameter(":C_TICK_NO",      OracleDbType.Varchar2, 100),
                new OracleParameter(":C_STL_GRD",      OracleDbType.Varchar2, 100),
                new OracleParameter(":C_SPEC",         OracleDbType.Varchar2, 100),
                new OracleParameter(":N_ENTRUST_TYPE", OracleDbType.Decimal,    1),
                new OracleParameter(":N_STATUS",       OracleDbType.Decimal,    1),
                new OracleParameter(":C_REMARK",       OracleDbType.Varchar2, 500),
                new OracleParameter(":C_EMP_ID_SY",    OracleDbType.Varchar2, 100),
                new OracleParameter(":D_MOD_DT_SY",    OracleDbType.Date),
                new OracleParameter(":C_EMP_ID_JS",    OracleDbType.Varchar2, 100),
                new OracleParameter(":D_MOD_DT_JS",    OracleDbType.Date),
                new OracleParameter(":C_EMP_ID_ZY",    OracleDbType.Varchar2, 100),
                new OracleParameter(":D_MOD_DT_ZY",    OracleDbType.Date),
                new OracleParameter(":C_EQ_NAME",      OracleDbType.Varchar2, 100),
                new OracleParameter(":C_EQ_NUMBER",    OracleDbType.Varchar2, 100),
                new OracleParameter(":C_EQ_CODE",      OracleDbType.Varchar2, 100),
                new OracleParameter(":N_SAMPLES_NUM",  OracleDbType.Decimal,    5),
                new OracleParameter(":D_MOD_DT",       OracleDbType.Date)
            };
            parameters[0].Value  = model.C_BATCH_NO;
            parameters[1].Value  = model.C_TICK_NO;
            parameters[2].Value  = model.C_STL_GRD;
            parameters[3].Value  = model.C_SPEC;
            parameters[4].Value  = model.N_ENTRUST_TYPE;
            parameters[5].Value  = model.N_STATUS;
            parameters[6].Value  = model.C_REMARK;
            parameters[7].Value  = model.C_EMP_ID_SY;
            parameters[8].Value  = model.D_MOD_DT_SY;
            parameters[9].Value  = model.C_EMP_ID_JS;
            parameters[10].Value = model.D_MOD_DT_JS;
            parameters[11].Value = model.C_EMP_ID_ZY;
            parameters[12].Value = model.D_MOD_DT_ZY;
            parameters[13].Value = model.C_EQ_NAME;
            parameters[14].Value = model.C_EQ_NUMBER;
            parameters[15].Value = model.C_EQ_CODE;
            parameters[16].Value = model.N_SAMPLES_NUM;
            parameters[17].Value = model.D_MOD_DT;

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

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

            strSql.Append("select C_ID,C_BATCH_NO,C_TICK_NO,C_STL_GRD,C_SPEC,N_ENTRUST_TYPE,N_STATUS,C_REMARK,C_EMP_ID_SY,D_MOD_DT_SY,C_EMP_ID_JS,D_MOD_DT_JS,C_EMP_ID_ZY,D_MOD_DT_ZY,C_EQ_NAME,C_EQ_NUMBER,C_EQ_CODE,N_SAMPLES_NUM,D_MOD_DT from TQC_PRESENT_SAMPLES_JSZX ");
            strSql.Append(" where C_ID=:C_ID ");
            OracleParameter[] parameters =
            {
                new OracleParameter(":C_ID", OracleDbType.Varchar2, 100)
            };
            parameters[0].Value = C_ID;

            Mod_TQC_PRESENT_SAMPLES_JSZX model = new Mod_TQC_PRESENT_SAMPLES_JSZX();
            DataSet ds = TransactionHelper.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Mod_TQC_PRESENT_SAMPLES_JSZX DataRowToModel(DataRow row)
        {
            Mod_TQC_PRESENT_SAMPLES_JSZX model = new Mod_TQC_PRESENT_SAMPLES_JSZX();

            if (row != null)
            {
                if (row["C_ID"] != null)
                {
                    model.C_ID = row["C_ID"].ToString();
                }
                if (row["C_BATCH_NO"] != null)
                {
                    model.C_BATCH_NO = row["C_BATCH_NO"].ToString();
                }
                if (row["C_TICK_NO"] != null)
                {
                    model.C_TICK_NO = row["C_TICK_NO"].ToString();
                }
                if (row["C_STL_GRD"] != null)
                {
                    model.C_STL_GRD = row["C_STL_GRD"].ToString();
                }
                if (row["C_SPEC"] != null)
                {
                    model.C_SPEC = row["C_SPEC"].ToString();
                }
                if (row["N_ENTRUST_TYPE"] != null && row["N_ENTRUST_TYPE"].ToString() != "")
                {
                    model.N_ENTRUST_TYPE = decimal.Parse(row["N_ENTRUST_TYPE"].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_SY"] != null)
                {
                    model.C_EMP_ID_SY = row["C_EMP_ID_SY"].ToString();
                }
                if (row["D_MOD_DT_SY"] != null && row["D_MOD_DT_SY"].ToString() != "")
                {
                    model.D_MOD_DT_SY = DateTime.Parse(row["D_MOD_DT_SY"].ToString());
                }
                if (row["C_EMP_ID_JS"] != null)
                {
                    model.C_EMP_ID_JS = row["C_EMP_ID_JS"].ToString();
                }
                if (row["D_MOD_DT_JS"] != null && row["D_MOD_DT_JS"].ToString() != "")
                {
                    model.D_MOD_DT_JS = DateTime.Parse(row["D_MOD_DT_JS"].ToString());
                }
                if (row["C_EMP_ID_ZY"] != null)
                {
                    model.C_EMP_ID_ZY = row["C_EMP_ID_ZY"].ToString();
                }
                if (row["D_MOD_DT_ZY"] != null && row["D_MOD_DT_ZY"].ToString() != "")
                {
                    model.D_MOD_DT_ZY = DateTime.Parse(row["D_MOD_DT_ZY"].ToString());
                }
                if (row["C_EQ_NAME"] != null)
                {
                    model.C_EQ_NAME = row["C_EQ_NAME"].ToString();
                }
                if (row["C_EQ_NUMBER"] != null)
                {
                    model.C_EQ_NUMBER = row["C_EQ_NUMBER"].ToString();
                }
                if (row["C_EQ_CODE"] != null)
                {
                    model.C_EQ_CODE = row["C_EQ_CODE"].ToString();
                }
                if (row["N_SAMPLES_NUM"] != null && row["N_SAMPLES_NUM"].ToString() != "")
                {
                    model.N_SAMPLES_NUM = decimal.Parse(row["N_SAMPLES_NUM"].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);
        }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update_Trans(Mod_TQC_PRESENT_SAMPLES_JSZX model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update TQC_PRESENT_SAMPLES_JSZX set ");
            strSql.Append("C_BATCH_NO=:C_BATCH_NO,");
            strSql.Append("C_TICK_NO=:C_TICK_NO,");
            strSql.Append("C_STL_GRD=:C_STL_GRD,");
            strSql.Append("C_SPEC=:C_SPEC,");
            strSql.Append("N_ENTRUST_TYPE=:N_ENTRUST_TYPE,");
            strSql.Append("N_STATUS=:N_STATUS,");
            strSql.Append("C_REMARK=:C_REMARK,");
            strSql.Append("C_EMP_ID_SY=:C_EMP_ID_SY,");
            strSql.Append("D_MOD_DT_SY=:D_MOD_DT_SY,");
            strSql.Append("C_EMP_ID_JS=:C_EMP_ID_JS,");
            strSql.Append("D_MOD_DT_JS=:D_MOD_DT_JS,");
            strSql.Append("C_EMP_ID_ZY=:C_EMP_ID_ZY,");
            strSql.Append("D_MOD_DT_ZY=:D_MOD_DT_ZY,");
            strSql.Append("C_EQ_NAME=:C_EQ_NAME,");
            strSql.Append("C_EQ_NUMBER=:C_EQ_NUMBER,");
            strSql.Append("C_EQ_CODE=:C_EQ_CODE,");
            strSql.Append("N_SAMPLES_NUM=:N_SAMPLES_NUM,");
            strSql.Append("D_MOD_DT=:D_MOD_DT");
            strSql.Append(" where C_ID=:C_ID ");
            OracleParameter[] parameters =
            {
                new OracleParameter(":C_BATCH_NO",     OracleDbType.Varchar2, 100),
                new OracleParameter(":C_TICK_NO",      OracleDbType.Varchar2, 100),
                new OracleParameter(":C_STL_GRD",      OracleDbType.Varchar2, 100),
                new OracleParameter(":C_SPEC",         OracleDbType.Varchar2, 100),
                new OracleParameter(":N_ENTRUST_TYPE", OracleDbType.Decimal,    1),
                new OracleParameter(":N_STATUS",       OracleDbType.Decimal,    1),
                new OracleParameter(":C_REMARK",       OracleDbType.Varchar2, 500),
                new OracleParameter(":C_EMP_ID_SY",    OracleDbType.Varchar2, 100),
                new OracleParameter(":D_MOD_DT_SY",    OracleDbType.Date),
                new OracleParameter(":C_EMP_ID_JS",    OracleDbType.Varchar2, 100),
                new OracleParameter(":D_MOD_DT_JS",    OracleDbType.Date),
                new OracleParameter(":C_EMP_ID_ZY",    OracleDbType.Varchar2, 100),
                new OracleParameter(":D_MOD_DT_ZY",    OracleDbType.Date),
                new OracleParameter(":C_EQ_NAME",      OracleDbType.Varchar2, 100),
                new OracleParameter(":C_EQ_NUMBER",    OracleDbType.Varchar2, 100),
                new OracleParameter(":C_EQ_CODE",      OracleDbType.Varchar2, 100),
                new OracleParameter(":N_SAMPLES_NUM",  OracleDbType.Decimal,    5),
                new OracleParameter(":D_MOD_DT",       OracleDbType.Date),
                new OracleParameter(":C_ID",           OracleDbType.Varchar2, 100)
            };
            parameters[0].Value  = model.C_BATCH_NO;
            parameters[1].Value  = model.C_TICK_NO;
            parameters[2].Value  = model.C_STL_GRD;
            parameters[3].Value  = model.C_SPEC;
            parameters[4].Value  = model.N_ENTRUST_TYPE;
            parameters[5].Value  = model.N_STATUS;
            parameters[6].Value  = model.C_REMARK;
            parameters[7].Value  = model.C_EMP_ID_SY;
            parameters[8].Value  = model.D_MOD_DT_SY;
            parameters[9].Value  = model.C_EMP_ID_JS;
            parameters[10].Value = model.D_MOD_DT_JS;
            parameters[11].Value = model.C_EMP_ID_ZY;
            parameters[12].Value = model.D_MOD_DT_ZY;
            parameters[13].Value = model.C_EQ_NAME;
            parameters[14].Value = model.C_EQ_NUMBER;
            parameters[15].Value = model.C_EQ_CODE;
            parameters[16].Value = model.N_SAMPLES_NUM;
            parameters[17].Value = model.D_MOD_DT;
            parameters[18].Value = model.C_ID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #5
0
        /// <summary>
        /// 接收
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_JS_SY_Click(object sender, EventArgs e)
        {
            try
            {
                bool IS_Success = true;

                string userID = RV.UI.UserInfo.userID;

                int[] rownumber = gv_SYXX.GetSelectedRows();//获取选中行号数组;

                if (rownumber.Length > 0)
                {
                    ArrayList SQLStringList = new ArrayList();

                    for (int i = 0; i < rownumber.Length; i++)
                    {
                        int selectedHandle = rownumber[i];

                        string strID = gv_SYXX.GetRowCellValue(selectedHandle, "取样主表主键").ToString();

                        Mod_TQC_PRESENT_SAMPLES_JSZX modJSZX = bllTqcPresentSamplesJszx.GetModel(strID);

                        if (modJSZX != null)
                        {
                            if (modJSZX.N_ENTRUST_TYPE == 3)
                            {
                                MessageBox.Show("批号:" + modJSZX.C_BATCH_NO + "钩号:" + modJSZX.C_TICK_NO + "已经接收送样,不能重复操作!");
                                IS_Success = false;
                                break;
                            }
                        }

                        SQLStringList.Add(" update tqc_present_samples_jszx set N_ENTRUST_TYPE=3,C_EMP_ID_ZY='" + userID + "',D_MOD_DT_ZY=SYSDATE where C_ID='" + strID + "' ");

                        Mod_TQC_PRESENT_SAMPLES mod = bllTqcPresentSamples.GetModel(strID);
                        if (mod != null)
                        {
                            DataTable dt_GroupID = bllTqcPresentSamplesName.Get_PHYSICS_GROUP_ID(strID, "技术中心", gv_SYXX.GetRowCellValue(selectedHandle, "执行标准").ToString(), gv_SYXX.GetRowCellValue(selectedHandle, "钢种").ToString()).Tables[0];

                            if (dt_GroupID.Rows.Count > 0)
                            {
                                for (int kk = 0; kk < dt_GroupID.Rows.Count; kk++)
                                {
                                    SQLStringList.Add(" insert into tqc_physics_result_main(C_BATCH_NO,C_TICK_NO,c_stl_grd,c_spec,c_emp_id,d_mod_dt,c_emp_id_zy,d_mod_dt_zy,c_emp_id_js,d_mod_dt_js,C_PHYSICS_GROUP_ID,C_CHECK_STATE,C_PRESENT_SAMPLES_ID)values('" + mod.C_BATCH_NO + "','" + mod.C_TICK_NO + "','" + mod.C_STL_GRD + "','" + mod.C_SPEC + "','" + mod.C_EMP_ID + "',to_date('" + mod.D_MOD_DT + "','yyyy-mm-dd hh24:mi:ss'),'" + userID + "',SYSDATE,'" + mod.C_EMP_ID_JS + "',to_date('" + mod.D_MOD_DT_JS + "','yyyy-mm-dd hh24:mi:ss'),'" + dt_GroupID.Rows[kk]["C_PHYSICS_GROUP_ID"].ToString() + "','0','" + strID + "' ) ");
                                }
                            }
                            else
                            {
                                string strGroupID = bllTqcPresentSamplesName.Get_GroupID();
                                if (!string.IsNullOrEmpty(strGroupID))
                                {
                                    SQLStringList.Add(" insert into tqc_physics_result_main(C_BATCH_NO,C_TICK_NO,c_stl_grd,c_spec,c_emp_id,d_mod_dt,c_emp_id_zy,d_mod_dt_zy,c_emp_id_js,d_mod_dt_js,C_PHYSICS_GROUP_ID,C_CHECK_STATE,C_PRESENT_SAMPLES_ID)values('" + mod.C_BATCH_NO + "','" + mod.C_TICK_NO + "','" + mod.C_STL_GRD + "','" + mod.C_SPEC + "','" + mod.C_EMP_ID + "',to_date('" + mod.D_MOD_DT + "','yyyy-mm-dd hh24:mi:ss'),'" + userID + "',SYSDATE,'" + mod.C_EMP_ID_JS + "',to_date('" + mod.D_MOD_DT_JS + "','yyyy-mm-dd hh24:mi:ss'),'" + strGroupID + "','0','" + strID + "' ) ");
                                }
                                else
                                {
                                    MessageBox.Show("取样名称和性能分组没有匹配关系,或者性能分组与执行标准钢种没有匹配关系!");
                                    IS_Success = false;
                                    break;
                                }
                            }
                        }
                    }

                    if (IS_Success)
                    {
                        if (bllTqcPresentSamplesName.SaveSamp(SQLStringList))
                        {
                            Common.UserLog.AddLog(strMenuName, this.Name, this.Text, "生成制样信息");//添加操作日志

                            MessageBox.Show("保存成功!");
                            BindSYXX_CG();
                            BindJYXX_CG();
                        }
                    }
                }
                else
                {
                    MessageBox.Show("请选择需要制样的信息!");
                    return;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Mod_TQC_PRESENT_SAMPLES_JSZX model)
 {
     return(dal.Update(model));
 }
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(Mod_TQC_PRESENT_SAMPLES_JSZX model)
 {
     return(dal.Add(model));
 }
        /// <summary>
        /// 保存性能值
        /// </summary>
        /// <returns></returns>
        public string Cancle_Sample(int[] rownumber, DataTable dt)
        {
            try
            {
                string result = "1";

                TransactionHelper.BeginTransaction();

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

                Dal_TQC_PRESENT_SAMPLES_JSZX dalJSZX   = new Dal_TQC_PRESENT_SAMPLES_JSZX();
                Dal_TQC_PHYSICS_RESULT_MAIN  dalMain   = new Dal_TQC_PHYSICS_RESULT_MAIN();
                Dal_TQC_PHYSICS_RESULT       dalResult = new Dal_TQC_PHYSICS_RESULT();

                for (int i = 0; i < rownumber.Length; i++)
                {
                    int selectedHandle = rownumber[i];

                    string strID = dt.Rows[selectedHandle]["取样主表主键"].ToString();

                    Mod_TQC_PRESENT_SAMPLES_JSZX modJSZX = dalJSZX.GetModel_Trans(strID);
                    if (modJSZX != null)
                    {
                        modJSZX.N_ENTRUST_TYPE = 2;
                        modJSZX.C_EMP_ID_ZY    = "";
                        modJSZX.D_MOD_DT_ZY    = null;

                        if (!dalJSZX.Update_Trans(modJSZX))
                        {
                            TransactionHelper.RollBack();
                            return("取消接样失败!");
                        }

                        Mod_TQC_PHYSICS_RESULT_MAIN modMain = dalMain.GetModel_Main(modJSZX.C_ID);

                        if (modMain != null)
                        {
                            int count = dalResult.Get_Count(modMain.C_ID);

                            if (count > 0)
                            {
                                TransactionHelper.RollBack();
                                return(modMain.C_BATCH_NO + "已录入性能值,不能取消接样!");
                            }
                            else
                            {
                                if (!dalMain.Delete_Trans(modMain.C_ID))
                                {
                                    TransactionHelper.RollBack();
                                    return("取消接样失败!");
                                }
                            }
                        }
                    }
                }

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