コード例 #1
0
        public Task <List <PreFligtManifest> > GetDataBufferStock()
        {
            using (var db = new OcphDbContext())
            {
                try
                {
                    var cmd = db.CreateCommand();
                    cmd.CommandText = "bufferstock";
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    var reader = cmd.ExecuteReader();
                    var result = MappingProperties <PreFligtManifest> .MappingTable(reader);

                    return(Task.FromResult(result.OrderBy(O => O.PTIId).ToList()));
                }
                catch (Exception ex)
                {
                    throw new SystemException(ex.Message);
                }
            }
        }
コード例 #2
0
        public Task <List <collies> > GetColliesOutOfSMU(int id)
        {
            try
            {
                using (var db = new OcphDbContext())
                {
                    var cmd = db.CreateCommand();
                    cmd.CommandText = "PTIColliesOutSMU";
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    cmd.Parameters.Add(new MySqlParameter("PtiId", id));
                    var reader = cmd.ExecuteReader();
                    var list   = MappingProperties <collies> .MappingTable(reader);

                    return(Task.FromResult(list));
                }
            }
            catch (Exception ex)
            {
                throw new SystemException(ex.Message);
            }
        }
コード例 #3
0
ファイル: SMUBussines.cs プロジェクト: TrireksaDevelopOrg/3MG
        public Task <List <collies> > GetSMUOutOfManifest(int id)
        {
            try
            {
                using (var db = new OcphDbContext())
                {
                    var cmd = db.CreateCommand();
                    cmd.CommandText = "PTIColliesOutSMU";
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    cmd.Parameters.Add(new MySqlParameter("ptiId", id));
                    var reader = cmd.ExecuteReader();
                    var result = MappingProperties <collies> .MappingTable(reader);

                    return(Task.FromResult(result));
                }
            }
            catch (Exception)
            {
                return(Task.FromResult(new List <collies>()));
            }
        }
コード例 #4
0
        public Task <List <BorderelCargoModel> > GetDataBorderelCargo(DateTime from)
        {
            using (var db = new OcphDbContext())
            {
                try
                {
                    var cmd = db.CreateCommand();
                    cmd.CommandText = "BorderelCargo";
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    cmd.Parameters.Add(new MySqlParameter("indate", from));
                    var reader = cmd.ExecuteReader();
                    var result = MappingProperties <BorderelCargoModel> .MappingTable(reader);

                    return(Task.FromResult(result));
                }
                catch (Exception ex)
                {
                    throw new SystemException(ex.Message);
                }
            }
        }
コード例 #5
0
        public Task <List <Deposit> > GetDepositsOfCustomer(customer value)
        {
            try
            {
                using (var db = new OcphDbContext())
                {
                    var cmd = db.CreateCommand();
                    cmd.CommandText = "DepositOfCustomer";
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    cmd.Parameters.Add(new MySqlParameter("id", value.Id));
                    var reader = cmd.ExecuteReader();
                    var list   = MappingProperties <Deposit> .MappingTable(reader);

                    return(Task.FromResult(list));
                }
            }
            catch (Exception)
            {
                return(Task.FromResult(new List <Deposit>()));
            }
        }
コード例 #6
0
        private Task <List <PenjualanReportModel> > GetPenjualan(string sp)
        {
            using (var db = new OcphDbContext())
            {
                try
                {
                    var cmd = db.CreateCommand();
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    cmd.CommandText = sp;
                    var dr   = cmd.ExecuteReader();
                    var list = MappingProperties <PenjualanReportModel> .MappingTable(dr);

                    dr.Close();

                    return(Task.FromResult(list));
                }
                catch (Exception ex)
                {
                    throw new SystemException(ex.Message);
                }
            }
        }
コード例 #7
0
ファイル: SMUBussines.cs プロジェクト: TrireksaDevelopOrg/3MG
        public Task <List <SMU> > GetSMU(DateTime startDate, DateTime endDate)
        {
            using (var db = new OcphDbContext())
            {
                try
                {
                    var cmd = db.CreateCommand();
                    cmd.CommandText = "SMU";
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    cmd.Parameters.Add(new MySqlParameter("startDate", startDate));
                    cmd.Parameters.Add(new MySqlParameter("endDate", endDate));
                    var reader = cmd.ExecuteReader();
                    var result = MappingProperties <SMU> .MappingTable(reader);

                    return(Task.FromResult(result));
                }
                catch (Exception ex)
                {
                    throw new SystemException(ex.Message);
                }
            }
        }
コード例 #8
0
        public Task <List <Penjualan> > GetDataLaporan(DateTime start, DateTime end)
        {
            using (var db = new OcphDbContext())
            {
                try
                {
                    var cmd = db.CreateCommand();
                    cmd.CommandText = "PenjualanByPTI";
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    cmd.Parameters.Add(new MySqlParameter("Dari", start));
                    cmd.Parameters.Add(new MySqlParameter("Sampai", end));
                    var reader = cmd.ExecuteReader();
                    var result = MappingProperties <Penjualan> .MappingTable(reader);

                    return(Task.FromResult(result));
                }
                catch (Exception ex)
                {
                    throw new SystemException(ex.Message);
                }
            }
        }
コード例 #9
0
        public Task <List <History> > GetPTIHistory(PTI selectedPTI)
        {
            List <History> list = null;

            try
            {
                using (var db = new OcphDbContext())
                {
                    var cmd = db.CreateCommand();
                    cmd.CommandText = "PTIHistories";
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    cmd.Parameters.Add(new MySqlParameter("id", selectedPTI.Id));
                    var reader = cmd.ExecuteReader();
                    list = MappingProperties <History> .MappingTable(reader);

                    return(Task.FromResult(list));
                }
            }
            catch (Exception)
            {
                return(Task.FromResult(list));
            }
        }
コード例 #10
0
        public Task <List <PreFligtManifest> > GetDataCargoterangkut(int siperID, DateTime from, DateTime to)
        {
            using (var db = new OcphDbContext())
            {
                try
                {
                    var cmd = db.CreateCommand();
                    cmd.CommandText = "terangkut";
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    cmd.Parameters.Add(new MySqlParameter("custId", siperID));
                    cmd.Parameters.Add(new MySqlParameter("startDate", from));
                    cmd.Parameters.Add(new MySqlParameter("endDate", to));
                    var reader = cmd.ExecuteReader();
                    var result = MappingProperties <PreFligtManifest> .MappingTable(reader);

                    return(Task.FromResult(result));
                }
                catch (Exception ex)
                {
                    throw new SystemException(ex.Message);
                }
            }
        }
コード例 #11
0
        public Task <bool> SetCancelPTI(PTI selectedPTI, string alasan)
        {
            using (var db = new OcphDbContext())
            {
                var trans = db.BeginTransaction();
                try
                {
                    var sp  = string.Format("Ptistatus");
                    var cmd = db.CreateCommand();

                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    cmd.CommandText = sp;
                    cmd.Parameters.Add(new MySql.Data.MySqlClient.MySqlParameter("Id", selectedPTI.Id));
                    var dr       = cmd.ExecuteReader();
                    var statuses = MappingProperties <PreFligtManifest> .MappingTable(dr);

                    dr.Close();
                    if (statuses != null && statuses.Count > 0)
                    {
                        if (statuses.Count > 1)
                        {
                            foreach (var item in statuses)
                            {
                                var man = db.Manifest.Where(O => O.Id == item.Id).FirstOrDefault();
                                if (man != null && !man.IsTakeOff)
                                {
                                    if (!db.ManifestDetail.Delete(O => O.SMUId == item.SMUId))
                                    {
                                        throw new SystemException(string.Format("PTI Tidak Dapat Dibatalkan, Keluarkan SMU T{0} dari Manifest MT{1}", item.SMUId, item.Id));
                                    }
                                }
                                else if (man != null && man.IsTakeOff)
                                {
                                    throw new SystemException(string.Format("PTI Tidak Dapat Dibatalkan, \r\n PTI telah diberangkatkan dengan Manifest MT{0:D8} \r\n dan SMU T{1:D9}", item.Id, item.SMUId));
                                }


                                if (item.SMUId > 0)
                                {
                                    ActivedStatus ac = ActivedStatus.Cancel;
                                    if (!db.SMU.Update(O => new { O.ActiveStatus }, new smu {
                                        ActiveStatus = ac
                                    }, O => O.Id == item.SMUId))
                                    {
                                        throw new SystemException("Tidak Dapat Membatalkan SMU");
                                    }
                                    var his = User.GenerateHistory(item.SMUId, BussinesType.SMU, ChangeType.Cancel,
                                                                   "System Membatalkan SMU NO " + item.SMUId + " Karena PTI  DI Batalkan : " + alasan);
                                    if (!db.Histories.Insert(his))
                                    {
                                        throw new SystemException("Gagal Diubah");
                                    }
                                }
                            }
                        }
                        else
                        {
                            var e = statuses.FirstOrDefault();
                            if (e != null && e.SMUId > 0 && e.Id > 0)
                            {
                                var man = db.Manifest.Where(O => O.Id == e.Id).FirstOrDefault();
                                if (man != null && man.IsTakeOff)
                                {
                                    throw new SystemException(string.Format("PTI Tidak Dapat Dibatalkan, \r\n PTI telah diberangkatkan dengan Manifest MT{0:D8} \r\n dan SMU T{1:D9}", e.Id, e.SMUId));
                                }
                                else if (man != null && !man.IsTakeOff)
                                {
                                    if (db.ManifestDetail.Delete(O => O.SMUId == e.SMUId))
                                    {
                                        var his = User.GenerateHistory(man.Id, BussinesType.Manifest, ChangeType.Update,
                                                                       "System Membatalkan SMU NO " + e.SMUId + " Dari Manifest No :" + man.Id + " Karena PTI  DI Batalkan : " + alasan);

                                        if (!db.Histories.Insert(his))
                                        {
                                            throw new SystemException("Gagal Diubah");
                                        }



                                        ActivedStatus ac = ActivedStatus.Cancel;
                                        if (!db.SMU.Update(O => new { O.ActiveStatus }, new smu {
                                            ActiveStatus = ac
                                        }, O => O.Id == e.SMUId))
                                        {
                                            throw new SystemException("Tidak Dapat Membatalkan SMU");
                                        }
                                        his = User.GenerateHistory(e.SMUId, BussinesType.SMU, ChangeType.Cancel,
                                                                   "System Membatalkan SMU NO " + e.SMUId + " Karena PTI  DI Batalkan : " + alasan);
                                        if (!db.Histories.Insert(his))
                                        {
                                            throw new SystemException("Gagal Diubah");
                                        }
                                    }
                                }
                            }
                        }
                    }

                    ActivedStatus active  = ActivedStatus.Cancel;
                    var           updated = db.PTI.Update(O => new { O.ActiveStatus }, new pti {
                        Id = selectedPTI.Id, ActiveStatus = active
                    }, O => O.Id == selectedPTI.Id);
                    if (updated)
                    {
                        selectedPTI.ActiveStatus = ActivedStatus.Cancel;
                        var his = User.GenerateHistory(selectedPTI.Id, BussinesType.PTI, ChangeType.Cancel, alasan);
                        if (!db.Histories.Insert(his))
                        {
                            throw new SystemException("Gagal Diubah");
                        }

                        trans.Commit();

                        return(Task.FromResult(true));
                    }
                    else
                    {
                        throw new SystemException("Gagal Diubah");
                    }
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    throw new SystemException(ex.Message);
                }
            }
        }