コード例 #1
0
        public Task <titipankapal> GetTitipanKapal(int ManifestId)
        {
            using (var db = new OcphDbContext())
            {
                try
                {
                    var sp  = string.Format("TitipanKapal");
                    var cmd = db.CreateCommand();
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    cmd.CommandText = sp;
                    cmd.Parameters.Add(new MySql.Data.MySqlClient.MySqlParameter("ManifestId", ManifestId));
                    var dr = cmd.ExecuteReader();

                    var ent  = new EntityInfo(typeof(ModelsShared.Models.titipankapal));
                    var list = new MappingColumn(ent).MappingWithoutInclud <titipankapal>(dr);
                    dr.Close();
                    titipankapal titip = null;
                    if (list.Count > 0)
                    {
                        titip        = list.FirstOrDefault();
                        titip.Jumlah = list.Count;
                    }
                    return(Task.FromResult(titip));
                }
                catch (Exception ex)
                {
                    throw new SystemException(ex.Message);
                }
            }
        }
コード例 #2
0
        public async Task <List <PenjualanOfYear> > GetPenjualanThreeYear()
        {
            var list = new List <ModelsShared.Models.PenjualanOfYear>();

            using (var db = new OcphDbContext())
            {
                var thisyear = DateTime.Now.Year;
                var sp       = string.Format("PenjualanOfaYear");
                var cmd      = db.CreateCommand();
                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                cmd.CommandText = sp;
                for (int i = thisyear; i > thisyear - 3; i--)
                {
                    cmd.Parameters.Add(new MySql.Data.MySqlClient.MySqlParameter("tahun", i));
                    var dr = cmd.ExecuteReader();

                    var ent = new EntityInfo(typeof(ModelsShared.Models.PenjualanOfYear));
                    list = new MappingColumn(ent).MappingWithoutInclud <PenjualanOfYear>(dr);
                    if (list.Count > 0)
                    {
                        var item = list.FirstOrDefault();
                        item.Months = await GetPenjualanOfMonth(item.Tahun);

                        list.Add(item);
                    }


                    cmd.Parameters.RemoveAt("tahun");
                    dr.Close();
                }
            }

            return(list);
        }
コード例 #3
0
        private Task <List <PenjualanOfMonth> > GetPenjualanOfMonth(int tahun)
        {
            var list = new List <ModelsShared.Models.PenjualanOfMonth>();

            using (var db = new OcphDbContext())
            {
                var sp  = string.Format("PenjualanOfamount");
                var cmd = db.CreateCommand();
                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                cmd.CommandText = sp;
                for (int i = 1; i <= 12; i++)
                {
                    var date = new DateTime(tahun, i, 1);
                    cmd.Parameters.Add(new MySql.Data.MySqlClient.MySqlParameter("Tanggal", date));
                    var dr     = cmd.ExecuteReader();
                    var ent    = new EntityInfo(typeof(ModelsShared.Models.PenjualanOfMonth));
                    var result = new MappingColumn(ent).MappingWithoutInclud <PenjualanOfMonth>(dr);
                    if (result.Count > 0)
                    {
                        var item = result.FirstOrDefault();
                        list.Add(item);
                    }


                    cmd.Parameters.RemoveAt("Tanggal");
                    dr.Close();
                }
            }

            return(Task.FromResult(list));
        }
コード例 #4
0
        public object GetLastItem()
        {
            List <T>   list = new List <T>();
            IDbCommand cmd  = connection.CreateCommand();

            cmd.CommandType = CommandType.Text;
            cmd.CommandText = "Select * From " + Entity.TableName + " Order By " + Entity.GetAttributPrimaryKeyName() + " Desc Limit 1";
            IDataReader dr = null;

            try
            {
                dr   = cmd.ExecuteReader() as MySqlDataReader;
                list = new MappingColumn(Entity).MappingWithoutInclud <T>(dr);
            }
            catch (Exception ex)
            {
                throw new SystemException(ex.Message);
            }
            finally
            {
                if (dr != null)
                {
                    dr.Close();
                }
            }
            return(list.FirstOrDefault());
        }