Exemple #1
0
 public static qscreqt InsertQscreqt(qscreqt _qscreqt)
 {
     try
     {
         OracleCommand cmd = new OracleCommand();
         //cmd.CommandText = string.Format(@"delete qcprot where vin=  '{0}'", CarUtility.GetVinWithoutChar(_QCProT.Vin), _QCProT.CreatedBy);
         //if (DBHelper.LiveDBConnectionIns.State == ConnectionState.Closed)
         //{
         //    DBHelper.LiveDBConnectionIns.ConnectionString = DBHelper.CnStrInsLive;
         //    DBHelper.LiveDBConnectionIns.Open();
         //}
         //cmd.Connection = DBHelper.LiveDBConnectionIns;
         //cmd.ExecuteNonQuery();
         //----
         cmd.CommandText = string.Format(@"insert into QSCREQT ( vin,CREATEDBY, mileage, qscapunt_srl, qscreft_srl, qscdtstt_srl, ReqDesc,u_date ) VALUES ('{0}',{1},{2},{3},{4},{5},'{6}',sysdate) returning Srl into :NewSrl",
                                         CarUtility.GetVinWithoutChar(_qscreqt.Vin), _qscreqt.CreatedBy, _qscreqt.Mileage, _qscreqt.QSCapunt_Srl, _qscreqt.QSCReft_Srl, _qscreqt.QSCDtstt_Ssrl, _qscreqt.ReqDesc);
         if (DBHelper.LiveDBConnectionQsc.State == ConnectionState.Closed)
         {
             DBHelper.LiveDBConnectionQsc.ConnectionString = DBHelper.CnStrQSCLive;
             DBHelper.LiveDBConnectionQsc.Open();
         }
         cmd.Connection = DBHelper.LiveDBConnectionQsc;
         cmd.Parameters.Add(":NewSrl", OracleDbType.Int32).Direction = ParameterDirection.Output;
         cmd.ExecuteNonQuery();
         Decimal NewQscreqt_Srl = Convert.ToDecimal(cmd.Parameters[0].Value.ToString());
         cmd.Parameters.Clear();
         //--
         List <int> lstRqRs = _qscreqt.Sel_qscrqrsnt_Srl.Cast <int>().ToList();
         for (int i = 0; i < lstRqRs.Count; i++)
         {
             cmd.CommandText = string.Format(@"insert into qscrqrsnt (qscreqt_srl, qscrsnt_srl) values ( {0}, {1})",
                                             NewQscreqt_Srl, lstRqRs[i]);
             cmd.ExecuteNonQuery();
         }
         //---
         //string commandtext = string.Format(@"select TO_char(p.createddate,'YYYY/MM/DD HH24:MI:SS','nls_calendar=persian') as ProCreatedDateFa
         //                                                ,u.UserId,u.fname ||' '|| u.lname as ProCreatedByDesc
         //                                                ,p.srl,p.vin,p.createdby,p.LocIsValid
         //                                                from qcprot p left join qcusert u on p.createdby = u.srl
         //                                                where vin ='{0}'", CarUtility.GetVinWithoutChar(_qscreqt.Vin));
         //QCProT p = DBHelper.GetDBObjectByObj2_OnLive(new QCProT(), null, commandtext, "inspector").Cast<QCProT>().ToList()[0];
         return(_qscreqt);
     }
     catch (Exception e)
     {
         DBHelper.LogtxtToFile("err_InsertQCProT_" + e.Message.ToString());
         DBHelper.LogFile(e);
         return(null);
     }
 }
Exemple #2
0
 public static QCProT InsertQCProT(QCProT _QCProT)
 {
     try
     {
         OracleCommand cmd = new OracleCommand();
         cmd.CommandText = string.Format(@"delete qcprot where vin=  '{0}'", CarUtility.GetVinWithoutChar(_QCProT.Vin), _QCProT.CreatedBy);
         if (DBHelper.LiveDBConnectionIns.State == ConnectionState.Closed)
         {
             DBHelper.LiveDBConnectionIns.ConnectionString = DBHelper.CnStrInsLive;
             DBHelper.LiveDBConnectionIns.Open();
         }
         cmd.Connection = DBHelper.LiveDBConnectionIns;
         cmd.ExecuteNonQuery();
         //----
         cmd.CommandText = string.Format(@"insert into qcprot (vin, createdby, createddate,LocIsValid) VALUES  ('{0}',{1},sysdate,{2})", CarUtility.GetVinWithoutChar(_QCProT.Vin), _QCProT.CreatedBy, _QCProT.LocIsValid);
         if (DBHelper.LiveDBConnectionIns.State == ConnectionState.Closed)
         {
             DBHelper.LiveDBConnectionIns.ConnectionString = DBHelper.CnStrInsLive;
             DBHelper.LiveDBConnectionIns.Open();
         }
         cmd.Connection = DBHelper.LiveDBConnectionIns;
         cmd.ExecuteNonQuery();
         //---
         string commandtext = string.Format(@"select TO_char(p.createddate,'YYYY/MM/DD HH24:MI:SS','nls_calendar=persian') as ProCreatedDateFa
                                                         ,u.UserId,u.fname ||' '|| u.lname as ProCreatedByDesc
                                                         ,p.srl,p.vin,p.createdby,p.LocIsValid
                                                         from qcprot p left join qcusert u on p.createdby = u.srl
                                                         where vin ='{0}'", CarUtility.GetVinWithoutChar(_QCProT.Vin));
         QCProT p           = DBHelper.GetDBObjectByObj2_OnLive(new QCProT(), null, commandtext, "inspector").Cast <QCProT>().ToList()[0];
         return(p);
     }
     catch (Exception e)
     {
         DBHelper.LogtxtToFile("err_InsertQCProT_" + e.Message.ToString());
         DBHelper.LogFile(e);
         return(null);
     }
 }
Exemple #3
0
 public static List <AuditCarDetail> GetAuditCarCheckList(AuditCarDetail auditcardetails)
 {
     try
     {
         if ((auditcardetails != null)) // && (U.Macaddress == "48:13:7e:11:d7:1f"))
         {
             auditcardetails.ValidFormat = CarUtility.CheckFormatVin(auditcardetails.Vin);
             if (auditcardetails.ValidFormat)
             {
                 auditcardetails.VinWithoutChar = CarUtility.GetVinWithoutChar(auditcardetails.Vin);
                 string  commandtext = string.Format(@"select d.srl,
                                                            a.vin,
                                                            a.areacode,
                                                            d.strenghtdesc,
                                                            d.modulecode,
                                                            d.defectcode,
                                                            d.modulename,
                                                            d.defectdesc,
                                                            d.title,
                                                            a.areacode || a.areadesc as AreaDesc,a.Auditor2,
                                                            a.Auditor2 as CreatedByDesc,
                                                            a.CreatedBy,
                                                            a.AUDITDATE_fa ||' '|| a.CREATEDTIME as AuditDateFa
                                                       from sva_v_auditcardetail d 
                                                            left join sva_v_auditcar a on a.srl = d.svaauditcar_srl
                                                       where a.vin = '{0}'
                                                     ", auditcardetails.Vin);
                 DataSet ds          = DBHelper.ExecuteMyQueryIns(commandtext);
                 // --
                 //string jsonString = string.Empty;
                 //jsonString = JsonConvert.SerializeObject(ds.Tables[0]);
                 //return jsonString;
                 // --
                 List <AuditCarDetail> FoundDefects = new List <AuditCarDetail>();
                 FoundDefects = DBHelper.GetDBObjectByObj2(new AuditCarDetail(), null, commandtext, "inspector").Cast <AuditCarDetail>().ToList();
                 //---
                 if (FoundDefects.Count > 0)
                 {
                     FoundDefects[0].ValidFormat    = auditcardetails.ValidFormat;
                     FoundDefects[0].VinWithoutChar = auditcardetails.VinWithoutChar;
                     FoundDefects[0].Msg            = auditcardetails.Msg = "";
                     return(FoundDefects);
                 }
                 else
                 {
                     List <AuditCarDetail> q = new List <AuditCarDetail>();
                     auditcardetails.Msg = "اطلاعاتی یافت نشد";
                     q.Add(auditcardetails);
                     return(null);
                 }
             }
             else
             {
                 List <AuditCarDetail> q = new List <AuditCarDetail>();
                 auditcardetails.Msg = "شاسی غیر مجاز است";
                 q.Add(auditcardetails);
                 return(q);
             }
         }
         else
         {
             DBHelper.LogtxtToFile("z null");
             return(null);
         }
     }
     catch (Exception e)
     {
         //string err = e.ToString() + e.InnerException.Message + e.Message.ToString();
         DBHelper.LogFile(e);
         List <AuditCarDetail> q = new List <AuditCarDetail>();
         auditcardetails.Msg = e.Message;
         q.Add(auditcardetails);
         return(q);
     }
 }