protected override void DataPortal_Create() { base.DataPortal_Create(); LoadProperty(_BillNo, "[Auto-Number]"); LoadProperty(_BillDate, DateTime.Now); LoadProperty(_DueDate, new SmartDate(new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month)))); LoadProperty(_BillType, CargoConstants.BillingType.Roro.Id); LoadProperty(_CreatedBy, 1); LoadProperty(_DateCreated, DateTime.Now); LoadProperty(_Status, CargoConstants.BillStatus.Draft.Id); LoadProperty(_BillItems, BillItemRoros.New()); this.BusinessRules.CheckRules(); }
private void DataPortal_Fetch(int id) { using (var ctx = ConnectionManager <SqlConnection> .GetManager(ConfigHelper.GetDatabase(), false)) { using (var cmd = ctx.Connection.CreateCommand()) { cmd.CommandText = string.Format(@" SELECT b.bill,b.billtype,b.billno,b.billdate,b.ornumber,b.consignee,b.billingaddress, c.contact AS {0}contact,c.code AS {0}code,c.name AS {0}name, v.contact AS {1}contact,v.code AS {1}code,v.name AS {1}name, b.billofladingno,b.voyageno,b.totalbill,b.duedate,b.status, billofladingno,b.createdby,b.datecreated,b.updatedby,b.dateupdated FROM bill b LEFT JOIN contact c ON b.consignee = c.contact LEFT JOIN contactaddress cca ON c.contact = cca.contact LEFT JOIN contact v ON b.vessel = v.contact LEFT JOIN contactaddress vca ON v.contact = vca.contact WHERE b.bill = @id", _Consignee.Name, _Vessel.Name); cmd.Parameters.AddWithValue("@id", id); using (var dr = new SafeDataReader(cmd.ExecuteReader())) { if (dr.Read()) { LoadProperty(_Id, dr.GetInt32("bill")); LoadProperty(_BillType, dr.GetInt32("billtype")); LoadProperty(_BillNo, dr.GetString("billno")); LoadProperty(_BillDate, dr.GetSmartDate("billdate")); LoadProperty(_ORNumber, dr.GetString("ornumber")); LoadProperty(_Consignee, BaseContactInfo.Get(dr, _Consignee.Name)); LoadProperty(_BillingAddress, dr.GetString("billingaddress")); LoadProperty(_Vessel, BaseContactInfo.Get(dr, _Vessel.Name)); LoadProperty(_BillOfLadingNo, dr.GetString("BillOfLadingNo")); LoadProperty(_VoyageNo, dr.GetString("voyageno")); LoadProperty(_TotalBill, dr.GetDecimal("totalbill")); LoadProperty(_DueDate, dr.GetSmartDate("duedate")); LoadProperty(_Status, dr.GetInt32("status")); LoadProperty(_CreatedBy, dr.GetInt32("createdby")); LoadProperty(_DateCreated, dr.GetSmartDate("datecreated")); LoadProperty(_UpdatedBy, dr.GetInt32("updatedby")); LoadProperty(_DateUpdated, dr.GetSmartDate("dateupdated")); } } } } LoadProperty(_BillItems, BillItemRoros.Get(new SingleCriteria <int>(this.Id))); }