コード例 #1
0
ファイル: PMS_Main_Model.Designer.cs プロジェクト: dinet/PMS
 /// <summary>
 /// Deprecated Method for adding a new object to the Declarations EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToDeclarations(Declaration declaration)
 {
     base.AddObject("Declarations", declaration);
 }
コード例 #2
0
ファイル: AddDeclaration.xaml.cs プロジェクト: dinet/PMS
        private void button2_Click(object sender, RoutedEventArgs e)
        {
            if (this.Validate())
            {
                Declaration declaration = new Declaration();
                string exporterName = txtExporter.Text;
                Exporter exporter;
                try
                {
                     exporter= model.Exporters.Where(exp => exp.Name == exporterName).FirstOrDefault();
                     declaration.Exporter = exporter;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Invalid Exporter Name");
                    return;
                }
                Buyer buyer;
                try
                {
                    buyer = model.Buyers.Where(buy => buy.Name == txtBuyer.Text).FirstOrDefault();
                    declaration.Buyer = buyer;
                }
                catch(Exception ex)
                {
                    MessageBox.Show("Invalid Buyer Name");
                    return;
                }
                Policy policy;
                try
                {
                    policy = model.Policies.Where(pol => pol.PolicyNumber == txtPolicyNo.Text).FirstOrDefault();
                    declaration.Policy = policy;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Invalid Policy Number");
                    return;
                }
                declaration.TermOfPayment = txtPaymentTerm.Text;
                declaration.Commodity = (Commodity)txtCommodity.SelectedItem;
                declaration.Country = (Country)txtCountry.SelectedItem;
                PremiumRate premium;
                try
                {
                    premium = declaration.Country.PremiumRates.Where(prem => prem.CommodityId == declaration.CommodityId).FirstOrDefault();
                    declaration.PremiumRate = premium;
                }
                catch (Exception ex)
                {
                }
                declaration.ShipmentDate = dtPickerShpDate.SelectedDate.Value;
                declaration.StampDate = dtPickerStampDate.SelectedDate.Value;
                declaration.GrossValue = txtGross.Text;
                declaration.CreditDuration = txtCreditDuration.Text;

                //Adding the declaration to the model
                model.AddToDeclarations(declaration);

                //Saving to the database
                model.SaveChanges();

                //Reloading the Datagrid
                this.LoadGrid();

            }
            else
            {
                return;
            }
        }
コード例 #3
0
ファイル: PMS_Main_Model.Designer.cs プロジェクト: dinet/PMS
 /// <summary>
 /// Create a new Declaration object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="exporterId">Initial value of the ExporterId property.</param>
 /// <param name="buyerId">Initial value of the BuyerId property.</param>
 /// <param name="policyId">Initial value of the PolicyId property.</param>
 /// <param name="commodityId">Initial value of the CommodityId property.</param>
 /// <param name="shipmentDate">Initial value of the ShipmentDate property.</param>
 /// <param name="termOfPayment">Initial value of the TermOfPayment property.</param>
 /// <param name="stampDate">Initial value of the StampDate property.</param>
 /// <param name="creditDuration">Initial value of the CreditDuration property.</param>
 /// <param name="countryId">Initial value of the CountryId property.</param>
 /// <param name="grossValue">Initial value of the GrossValue property.</param>
 public static Declaration CreateDeclaration(global::System.Int32 id, global::System.Int32 exporterId, global::System.Int32 buyerId, global::System.Int32 policyId, global::System.Int32 commodityId, global::System.DateTime shipmentDate, global::System.String termOfPayment, global::System.DateTime stampDate, global::System.String creditDuration, global::System.Int32 countryId, global::System.String grossValue)
 {
     Declaration declaration = new Declaration();
     declaration.Id = id;
     declaration.ExporterId = exporterId;
     declaration.BuyerId = buyerId;
     declaration.PolicyId = policyId;
     declaration.CommodityId = commodityId;
     declaration.ShipmentDate = shipmentDate;
     declaration.TermOfPayment = termOfPayment;
     declaration.StampDate = stampDate;
     declaration.CreditDuration = creditDuration;
     declaration.CountryId = countryId;
     declaration.GrossValue = grossValue;
     return declaration;
 }