public Task <List <PTI> > GetPTIFromTo(DateTime startDate, DateTime endDate) { var list = new List <PTI>(); try { using (var db = new OcphDbContext()) { var sp = string.Format("PtiFromTo"); var cmd = db.CreateCommand(); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.CommandText = sp; cmd.Parameters.Add(new MySql.Data.MySqlClient.MySqlParameter("startDate", startDate)); cmd.Parameters.Add(new MySql.Data.MySqlClient.MySqlParameter("endDate", endDate)); var dr = cmd.ExecuteReader(); list = MappingProperties <PTI> .MappingTable(dr); dr.Close(); return(Task.FromResult(list)); } } catch (Exception ex) { throw new SystemException(ex.Message); } }
public IEnumerable <penjualan> Get(DateTime start, DateTime end) { using (var db = new OcphDbContext()) { var sp = string.Format("GetPenjualans"); var cmd = db.CreateCommand(); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.CommandText = sp; cmd.Parameters.Add(new MySql.Data.MySqlClient.MySqlParameter("StartDate", start)); cmd.Parameters.Add(new MySql.Data.MySqlClient.MySqlParameter("EndDate", end)); var dr = cmd.ExecuteReader(); var list = MappingProperties <penjualan> .MappingTable(dr); dr.Close(); foreach (var item in list) { item.Details = db.Collies.Where(O => O.PenjualanId == item.Id).ToList(); item.Shiper = db.Customers.Where(O => O.Id == item.ShiperID).FirstOrDefault(); if (item.Shiper != null) { item.Shiper.City = db.Cities.Where(O => O.Id == item.Shiper.CityID).FirstOrDefault(); } item.Reciver = db.Customers.Where(O => O.Id == item.ReciverID).FirstOrDefault(); if (item.Reciver != null) { item.Reciver.City = db.Cities.Where(O => O.Id == item.Reciver.CityID).FirstOrDefault(); } item.DeliveryStatus = db.DeliveryStatusses.Where(O => O.PenjualanId == item.Id).FirstOrDefault(); } return(list); } }
public List <PenjualanReportModel> GetPenjualanFromTo(DateTime startDate, DateTime ended) { using (var db = new OcphDbContext()) { try { var sp = string.Format("GetPenjualanFromTo"); var cmd = db.CreateCommand(); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.CommandText = sp; cmd.Parameters.Add(new MySql.Data.MySqlClient.MySqlParameter("startDate", startDate)); cmd.Parameters.Add(new MySql.Data.MySqlClient.MySqlParameter("ended", ended)); var dr = cmd.ExecuteReader(); var list = MappingProperties <PenjualanReportModel> .MappingTable(dr); dr.Close(); foreach (var item in list) { item.From = startDate; item.To = ended; } return(list); } catch (Exception ex) { throw new SystemException(ex.Message); } } }
public Task <List <Manifest> > GetManifest(DateTime start, DateTime end) { try { using (var db = new OcphDbContext()) { var cmd = db.CreateCommand(); cmd.CommandText = "ManifestFromTo"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new MySqlParameter("startDate", start)); cmd.Parameters.Add(new MySqlParameter("endDate", end)); var reader = cmd.ExecuteReader(); var result = MappingProperties <Manifest> .MappingTable(reader); if (result.Count <= 0) { throw new SystemException("Data TIdak Ada"); } return(Task.FromResult(result)); } } catch (Exception ex) { throw new SystemException(ex.Message); } }
public Task <List <SMUDetail> > GetSMUDetail(int id) { try { using (var db = new OcphDbContext()) { var cmd = db.CreateCommand(); cmd.CommandText = "SMUDetail"; cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.Add(new MySqlParameter("id", id)); var reader = cmd.ExecuteReader(); var result = MappingProperties <SMUDetail> .MappingTable(reader); if (result.Count < 0) { throw new SystemException("Detail SMU Tidak Ditemukan"); } return(Task.FromResult(result)); } } catch (Exception ex) { throw new SystemException(ex.Message); } }
public invoice Get(int Id) { using (var db = new OcphDbContext()) { try { var inv = db.Invoices.Where(O => O.Id == Id).FirstOrDefault(); var cmd = db.CreateCommand(); cmd.CommandText = "InvoiceDetail"; cmd.Parameters.Add(new MySqlParameter("invoiceId", Id)); cmd.CommandType = System.Data.CommandType.StoredProcedure; var reader = cmd.ExecuteReader(); var result = MappingProperties <invoicedetail> .MappingTable(reader); reader.Close(); if (inv != null) { inv.Details = result; } return(inv); } catch (Exception ex) { throw new SystemException(ex.Message); } } }
public Task <List <Saldo> > GetRekeningKorang(DateTime tanggal, int ShiperId) { DateTime now = new DateTime(tanggal.Year, tanggal.Month, tanggal.Day); try { using (var db = new OcphDbContext()) { var cmd = db.CreateCommand(); cmd.CommandText = "SaldoAkhirSebelumTanggal"; cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.Add(new MySqlParameter("tanggal", now)); cmd.Parameters.Add(new MySqlParameter("custId", ShiperId)); var saldoAkhir = (double)cmd.ExecuteScalar(); cmd.Parameters.Clear(); cmd.CommandText = "DebetFromDate"; cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.Add(new MySqlParameter("tanggal", tanggal)); cmd.Parameters.Add(new MySqlParameter("custId", ShiperId)); var reader = cmd.ExecuteReader(); var DataDebet = MappingProperties <SMU> .MappingTable(reader); reader.Close(); var deposit = db.Deposit.Where(O => O.CustomerId == ShiperId && O.CreatedDate >= now).ToList(); List <Saldo> list = new List <Saldo>(); list.Add(new Models.Saldo { SaldoAkhir = saldoAkhir, Tanggal = now.AddDays(-1), Description = "Saldo Awal" }); foreach (var item in DataDebet) { list.Add(new Saldo { Description = string.Format("SMU T{0:D9}", item.Id), Debet = item.Biaya, SMUId = item.Id, PTIId = item.PTIId, Tanggal = item.CreatedDate, Biaya = item.Biaya - (item.Biaya * 0.1), CreatedDate = item.CreatedDate, ManifestId = item.ManifestId, Pcs = item.Pcs, PPN = item.PPN, ReciverName = item.RecieverName, Total = item.Biaya, Weight = item.Weight }); } foreach (var item in deposit) { list.Add(new Saldo { Description = "Deposit", Kredit = item.Jumlah, Tanggal = item.CreatedDate }); } return(Task.FromResult(list.OrderBy(O => O.Tanggal).ToList())); } } catch (Exception) { return(Task.FromResult(new List <Saldo>())); } }
/// <summary> /// Validate the object. /// </summary> /// <exception cref="ValidationException"> /// Thrown if validation fails /// </exception> public virtual void Validate() { if (EntityTypeName == null) { throw new ValidationException(ValidationRules.CannotBeNull, "EntityTypeName"); } if (MappingProperties == null) { throw new ValidationException(ValidationRules.CannotBeNull, "MappingProperties"); } if (MappingProperties != null) { MappingProperties.Validate(); } }
public override void OnFieldDoubleClick(ShapeField field, DiagramPointEventArgs e) { string property_Name = this.ModelElement.GetProperties()["Name"].GetValue(this.ModelElement.GetProperties()["Name"]).ToString(); string property_Description = this.ModelElement.GetProperties()["Description"].GetValue(this.ModelElement.GetProperties()["Description"]).ToString(); MappingProperties mappingProperties = new MappingProperties(); mappingProperties.NameTextBox = property_Name; mappingProperties.DescriptionTextBox = property_Description; if (mappingProperties.ShowDialog() == DialogResult.OK) { this.ModelElement.GetProperties()["Name"].SetValue(this.ModelElement.GetProperties()["Name"], mappingProperties.NameTextBox); this.ModelElement.GetProperties()["Description"].SetValue(this.ModelElement.GetProperties()["Description"], mappingProperties.DescriptionTextBox); } }
public IEnumerable <invoice> Get(DateTime start, DateTime end) { using (var db = new OcphDbContext()) { var cmd = db.CreateCommand(); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.CommandText = "GetAllInvoice"; cmd.Parameters.Add(new MySqlParameter("StartDate", start)); cmd.Parameters.Add(new MySqlParameter("EndDate", end)); var reader = cmd.ExecuteReader(); var result = MappingProperties <invoice> .MappingTable(reader); return(result); } }
public Task <List <SMU> > GetSMUForCreateManifest() { using (var db = new OcphDbContext()) { var cmd = db.CreateCommand(); cmd.CommandText = "SMUForManifest"; cmd.CommandType = CommandType.StoredProcedure; var reader = cmd.ExecuteReader(); var result = MappingProperties <SMU> .MappingTable(reader); if (result.Count <= 0) { throw new SystemException("Data TIdak Ada"); } return(Task.FromResult(result)); } }
public Task <List <SMU> > ManifestDetails(Manifest selected) { using (var db = new OcphDbContext()) { var cmd = db.CreateCommand(); cmd.CommandText = "ManifestDetails"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new MySqlParameter("id", selected.Id)); var reader = cmd.ExecuteReader(); var result = MappingProperties <SMU> .MappingTable(reader); if (result.Count <= 0) { throw new SystemException("Manifest Ini Telah Kosong, Sebaiknya Anda Batalkan"); } return(Task.FromResult(result)); } }
public Task <List <PreFligtManifest> > ManifestPreFlightDetails(Manifest selected) { using (var db = new OcphDbContext()) { var cmd = db.CreateCommand(); cmd.CommandText = "PreFlight"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new MySqlParameter("id", selected.Id)); var reader = cmd.ExecuteReader(); var result = MappingProperties <PreFligtManifest> .MappingTable(reader); if (result.Count <= 0) { throw new SystemException("Data TIdak Ada"); } return(Task.FromResult(result)); } }
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); } } }
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>())); } }
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); } }
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); } } }
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>())); } }
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); } } }
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); } } }
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); } } }
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); } } }
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)); } }
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); } } }