예제 #1
0
        public static void CompleteScaling(Guid truckId)
        {
            IGINProcess    ginProcess  = GetGINProcess(true);
            SqlTransaction transaction = null;

            try
            {
                transaction = ginProcess.CompleteScaling(truckId);
                TruckRegistrationInfo truckReistration = new TruckRegistrationInfo()
                {
                    GINTruck = ginProcess.GINProcessInformation.Trucks.Find(t => t.TruckId == truckId)
                };
                TruckWeight trackWeight = truckReistration.TruckWeight;
                trackWeight.Id = Guid.NewGuid();
                trackWeight.Save(transaction);
                CompleteWorkflowTask(ginProcess.GINProcessInformation.Trucks[0].TransactionId);
                transaction.Commit();
            }
            catch (Exception ex)
            {
                try
                {
                    if (transaction != null)
                    {
                        transaction.Rollback();
                    }
                }
                catch (Exception ex2)
                {
                    throw ex2;
                }
                throw ex;
            }
        }
예제 #2
0
        public static TruckWeight GetLatestActivetTruckTrailerWeight(string TruckPlateNo, string TrailerPlateNo)
        {
            TruckWeight        obj    = null;
            string             strSql = "spGetLatestTruckTrailerWeight";
            List <TruckWeight> list   = null;
            SqlConnection      conn   = null;
            SqlDataReader      reader;

            SqlParameter[] arPar = new SqlParameter[2];
            try
            {
                arPar[0] = new SqlParameter("@TruckPlateNo", SqlDbType.NVarChar, 50);
                if (string.IsNullOrEmpty(TruckPlateNo) == true)
                {
                    arPar[0].Value = DBNull.Value;
                }
                else
                {
                    arPar[0].Value = TruckPlateNo;
                }

                arPar[1] = new SqlParameter("@TrailerPlateNo", SqlDbType.NVarChar, 50);
                if (string.IsNullOrEmpty(TrailerPlateNo) == true)
                {
                    arPar[1].Value = DBNull.Value;
                }
                else
                {
                    arPar[1].Value = TrailerPlateNo;
                }

                conn   = Connection.getConnection();
                reader = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, strSql, arPar);
                if (reader.HasRows)
                {
                    list = new List <TruckWeight>();
                    reader.Read();
                    obj = new TruckWeight();
                    if (reader["Id"] != DBNull.Value)
                    {
                        obj.Id = new Guid(reader["Id"].ToString());
                    }
                    obj.TruckPlateNo   = reader["TruckPlateNo"].ToString();
                    obj.TrailerPlateNo = reader["TrailerPlateNo"].ToString();
                    if (reader["hasTrailer"] != DBNull.Value)
                    {
                        obj.hasTrailer = (TruckHasTrailerType)int.Parse(reader["hasTrailer"].ToString());
                    }
                    if (reader["Weight"] != DBNull.Value)
                    {
                        obj.Weight = float.Parse(reader["Weight"].ToString());
                    }
                    if (reader["DateWeighed"] != DBNull.Value)
                    {
                        obj.DateWeighed = DateTime.Parse(reader["DateWeighed"].ToString());
                    }

                    if (reader["Status"] != DBNull.Value)
                    {
                        obj.Status = (TruckWeightStatus)int.Parse(reader["Status"].ToString());
                    }
                    if (reader["CreatedBy"] != DBNull.Value)
                    {
                        obj.CreatedBy = new Guid(reader["CreatedBy"].ToString());
                    }
                    if (reader["CreatedTimestamp"] != DBNull.Value)
                    {
                        obj.CreatedTimestamp = DateTime.Parse(reader["CreatedTimestamp"].ToString());
                    }

                    if (reader["LastModifiedBy"] != DBNull.Value)
                    {
                        obj.LastModifiedBy = new Guid(reader["LastModifiedBy"].ToString());
                    }
                    if (reader["LastModifiedTimestamp"] != DBNull.Value)
                    {
                        obj.CreatedTimestamp = DateTime.Parse(reader["LastModifiedTimestamp"].ToString());
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (conn != null)
                {
                    if (conn.State == ConnectionState.Open)
                    {
                        conn.Close();
                    }
                }
            }



            return(obj);
        }
예제 #3
0
        public static bool InsertNew(TruckWeight obj)
        {
            DataAccessPoint dal    = new DataAccessPoint();
            string          strSql = "spInsertTruckWeight";

            SqlParameter[] arPar = new SqlParameter[8];
            try
            {
                arPar[0]       = new SqlParameter("@Id", SqlDbType.UniqueIdentifier);
                arPar[0].Value = obj.Id;

                arPar[1] = new SqlParameter("@TruckPlateNo", SqlDbType.NVarChar, 50);
                if (string.IsNullOrEmpty(obj.TruckPlateNo) == true)
                {
                    arPar[1].Value = DBNull.Value;
                }
                else
                {
                    arPar[1].Value = obj.TruckPlateNo;
                }

                arPar[2] = new SqlParameter("@TrailerPlateNo", SqlDbType.NVarChar, 50);
                if (string.IsNullOrEmpty(obj.TrailerPlateNo) == true)
                {
                    arPar[2].Value = DBNull.Value;
                }
                else
                {
                    arPar[2].Value = obj.TrailerPlateNo;
                }


                arPar[3]       = new SqlParameter("@hasTrailer", SqlDbType.Int);
                arPar[3].Value = (int)obj.hasTrailer;

                arPar[4]       = new SqlParameter("@Weight", SqlDbType.Float);
                arPar[4].Value = obj.Weight;

                arPar[5]       = new SqlParameter("@DateWeighed", SqlDbType.DateTime);
                arPar[5].Value = obj.DateWeighed;

                arPar[6]       = new SqlParameter("@Status", SqlDbType.Int);
                arPar[6].Value = (int)obj.Status;

                arPar[7]       = new SqlParameter("@CreatedBy", SqlDbType.UniqueIdentifier);
                arPar[7].Value = obj.CreatedBy;

                int Affeccted = -1;

                if (dal.ExcuteProcedure(strSql, arPar))
                {
                    Affeccted = 1;
                }
                if (Affeccted == 1)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Unable to Add Truck Weight", ex);
            }
        }
예제 #4
0
 public static bool Update(TruckWeight obj, SqlTransaction tran)
 {
     return(true);
 }
예제 #5
0
        public static bool Insert(TruckWeight obj, SqlTransaction tran)
        {
            string strSql = "spInsertTruckWeight";

            SqlParameter[] arPar = new SqlParameter[8];
            try
            {
                arPar[0]       = new SqlParameter("@Id", SqlDbType.UniqueIdentifier);
                arPar[0].Value = obj.Id;

                arPar[1] = new SqlParameter("@TruckPlateNo", SqlDbType.NVarChar, 50);
                if (string.IsNullOrEmpty(obj.TruckPlateNo) == true)
                {
                    arPar[1].Value = DBNull.Value;
                }
                else
                {
                    arPar[1].Value = obj.TruckPlateNo;
                }

                arPar[2] = new SqlParameter("@TrailerPlateNo", SqlDbType.NVarChar, 50);
                if (string.IsNullOrEmpty(obj.TrailerPlateNo) == true)
                {
                    arPar[2].Value = DBNull.Value;
                }
                else
                {
                    arPar[2].Value = obj.TrailerPlateNo;
                }


                arPar[3]       = new SqlParameter("@hasTrailer", SqlDbType.Int);
                arPar[3].Value = (int)obj.hasTrailer;

                arPar[4]       = new SqlParameter("@Weight", SqlDbType.Float);
                arPar[4].Value = obj.Weight;

                arPar[5]       = new SqlParameter("@DateWeighed", SqlDbType.DateTime);
                arPar[5].Value = obj.DateWeighed;

                arPar[6]       = new SqlParameter("@Status", SqlDbType.Int);
                arPar[6].Value = (int)obj.Status;

                arPar[7]       = new SqlParameter("@CreatedBy", SqlDbType.UniqueIdentifier);
                arPar[7].Value = obj.CreatedBy;

                int Affeccted = -1;

                Affeccted = SqlHelper.ExecuteNonQuery(tran, CommandType.StoredProcedure, strSql, arPar);

                if (Affeccted == 1)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Unable to Add Truck Weight", ex);
            }
        }