コード例 #1
0
        private void dropCurrency_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if ((txtAddTotalCost.Text != null && txtAddTotalCost.Text != "") && (txtAddCPP.Text != null && txtAddCPP.Text != ""))
            {
                int No = Convert.ToInt32(txtAddNoPieces.Text);
                double PPP = Convert.ToDouble(txtAddPricePiece.Text);
                double Trans = Convert.ToDouble(txtAddTrans.Text);
                double SupCom = Convert.ToDouble(txtAddSupComm.Text);
                double Misc = Convert.ToDouble(txtAddMisc.Text);

                StockLotPurchaseHandle stl = new StockLotPurchaseHandle();

                double total = Convert.ToDouble(stl.CalcTotShipment(No, PPP, Trans, SupCom, Misc));
                //txtAddTotalCost.Text = value1.ToString("0.00");

                double actual = Convert.ToDouble(stl.CalcCPP(No, PPP, Trans, SupCom, Misc));
                //txtAddCPP.Text = value2.ToString("0.00");

                double trueTotal = 0;
                double trueActual = 0;
                if (dropCurrency.SelectedValue.ToString() != "LKR")
                {

                    using (adoraDBContext a = new adoraDBContext())
                    {
                        var id = (from ee in a.CurCategories
                                  where (ee.Category == dropCurrency.SelectedValue.ToString())
                                  select ee.CurCatID).SingleOrDefault();
                        var val = (from s in a.Currencies
                                   where s.CurrencyCategory == id
                                   select s.Value).ToList();

                        double value = Convert.ToDouble(val.Last());
                        trueTotal = total / value;
                        trueActual = actual / value;
                    }
                }
                else
                {
                    trueTotal = total;
                    trueActual = actual;
                }

                //MessageBox.Show(dropCurrency.SelectedValue.ToString());

                txtAddTotalCost.Text = trueTotal.ToString("F");
                txtAddCPP.Text = trueActual.ToString("F");

                curlbl1.Content = dropCurrency.SelectedValue.ToString();
                curlbl2.Content = dropCurrency.SelectedValue.ToString();
            }
        }
コード例 #2
0
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            ValidateValues();

            bool a = lblAddNoPieces.IsVisible;
            bool b = lblAddTrans.IsVisible;
            bool c = lblAddSupCom.IsVisible;
            bool d = lblAddMisc.IsVisible;
            bool f = lblAddPPP.IsVisible;
            bool g = lblAddDate.IsVisible;
            bool h = lblAddShipName.IsVisible;

            if (a || b || c || d || f || g || h)
            {
                MessageBox.Show("Check Values Again", "Message");
            }
            else
            {
                StockLotPurchaseHandle stl = new StockLotPurchaseHandle();

                int No = Convert.ToInt32(txtAddNoPieces.Text);
                double PPP = Convert.ToDouble(txtAddPricePiece.Text);
                double Trans = Convert.ToDouble(txtAddTrans.Text);
                double SupCom = Convert.ToDouble(txtAddSupComm.Text);
                double Misc = Convert.ToDouble(txtAddMisc.Text);

                double total = stl.CalcTotShipment(No, PPP, Trans, SupCom, Misc);
                double actualcostpp = stl.CalcCPP(No, PPP, Trans, SupCom, Misc);

                decimal pPPP = Convert.ToDecimal(PPP);
                decimal pTrans = Convert.ToDecimal(Trans);
                decimal pSupCom = Convert.ToDecimal(SupCom);
                decimal pMisc = Convert.ToDecimal(Misc);
                string pShipName = txtAddShipName.Text;
                DateTime pDate = Convert.ToDateTime(txtAddDate.Text);

                try
                {
                    PurchasingShipment ps = new PurchasingShipment();
                    ps.date = pDate;
                    ps.Title = pShipName;
                    ps.PricePerPiece = pPPP;
                    ps.NoOfPieces = No;
                    ps.SupplierCommission = pSupCom;
                    ps.TransportCost = pTrans;
                    ps.Micelleneous = pMisc;

                    _context.PurchasingShipments.Add(ps);
                    _context.SaveChanges();

                    this.purchasingShipmentDataGrid.Items.Refresh();
                    _context.PurchasingShipments.Load();
                    System.Windows.MessageBox.Show("Succesfully Added", "Done", MessageBoxButton.OK, MessageBoxImage.Information);

                    populateShipmentNames(txtDelShipName);
                    /*
                    string sql = "insert into PurchasingShipments(Title,Date,NoOfPieces,PricePerPiece,TransportCost,SupplierCommission,Micelleneous)" +
                                    "values(@P0,@P1,@P2,@P3,@P4,@P5,@P6)";

                    List<object> parameterList = new List<object>();
                    parameterList.Add(txtAddShipName.Text);
                    parameterList.Add(Convert.ToDateTime(txtAddDate.Text));
                    parameterList.Add(Convert.ToInt32(txtAddNoPieces.Text));
                    parameterList.Add(Convert.ToDecimal(txtAddPricePiece.Text));
                    parameterList.Add(Convert.ToDecimal(txtAddTrans.Text));
                    parameterList.Add(Convert.ToDecimal(txtAddSupComm.Text));
                    parameterList.Add(Convert.ToDecimal(txtAddMisc.Text));

                    

                    object[] parameters1 = parameterList.ToArray();
                    
                    int result = _context.Database.ExecuteSqlCommand(sql, parameters1);

                    _context.SaveChanges();
                    this.purchasingShipmentDataGrid.Items.Refresh();
                    _context.UserTypes.Load();
                    */

                    

                    refresh();
                    reset();
                    
                }
                catch(Exception)
                {
                }
                    
            }
        }
コード例 #3
0
        private void btnEdit_Click(object sender, RoutedEventArgs e)
        {
            ValidateValues();

            bool a = lblAddNoPieces.IsVisible;
            bool b = lblAddTrans.IsVisible;
            bool c = lblAddSupCom.IsVisible;
            bool d = lblAddMisc.IsVisible;
            bool f = lblAddPPP.IsVisible;
            bool g = lblAddDate.IsVisible;
            bool h = lblAddShipName.IsVisible;

            if (a || b || c || d || f || g || h)
            {
                MessageBox.Show("Check Values Again", "Message");
            }
            else
            {
                StockLotPurchaseHandle stl = new StockLotPurchaseHandle();

                int No = Convert.ToInt32(txtAddNoPieces.Text);
                double PPP = Convert.ToDouble(txtAddPricePiece.Text);
                double Trans = Convert.ToDouble(txtAddTrans.Text);
                double SupCom = Convert.ToDouble(txtAddSupComm.Text);
                double Misc = Convert.ToDouble(txtAddMisc.Text);
                string ShipID = lblShipID.Content.ToString();

                double total = stl.CalcTotShipment(No, PPP, Trans, SupCom, Misc);
                double actualcostpp = stl.CalcCPP(No, PPP, Trans, SupCom, Misc);

                decimal pPPP = Convert.ToDecimal(PPP);
                decimal pTrans = Convert.ToDecimal(Trans);
                decimal pSupCom = Convert.ToDecimal(SupCom);
                decimal pMisc = Convert.ToDecimal(Misc);
                string pShipName = txtAddShipName.Text;
                DateTime pDate = Convert.ToDateTime(txtAddDate.Text);
                

                try
                {
                    adoraDBContext con = new adoraDBContext();
                    PurchasingShipment ps = _context.PurchasingShipments.First(i => i.ShipmentID == ShipID);
                    ps.PricePerPiece = pPPP;
                    ps.TransportCost = pTrans;
                    ps.SupplierCommission = pSupCom;
                    ps.Micelleneous = pMisc;
                    ps.Title = pShipName;
                    ps.date = pDate;

                    _context.SaveChanges();
                    populateShipmentNames(txtDelShipName);
                    this.purchasingShipmentDataGrid.Items.Refresh();
                    _context.PurchasingShipments.Load();
                    System.Windows.MessageBox.Show("Succesfully Updated", "Done", MessageBoxButton.OK, MessageBoxImage.Information);
                    refresh();
                    reset();

                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }

            }

        }
コード例 #4
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            
            StockLotPurchaseHandle stl = new StockLotPurchaseHandle();

            ValidateNumbers();

            bool a = lblAddNoPieces.IsVisible;
            bool b = lblAddTrans.IsVisible;
            bool c = lblAddSupCom.IsVisible;
            bool d = lblAddMisc.IsVisible;
            bool f = lblAddPPP.IsVisible;

            if ( !a && !b && !c && !d && !f)
            {
                int No = Convert.ToInt32(txtAddNoPieces.Text);
                double PPP = Convert.ToDouble(txtAddPricePiece.Text);
                double Trans = Convert.ToDouble(txtAddTrans.Text);
                double SupCom = Convert.ToDouble(txtAddSupComm.Text);
                double Misc = Convert.ToDouble(txtAddMisc.Text);
                
                decimal value1 = Convert.ToDecimal(stl.CalcTotShipment(No,PPP, Trans, SupCom, Misc));
                txtAddTotalCost.Text = value1.ToString("0.00");

                decimal value2 = Convert.ToDecimal(stl.CalcCPP(No, PPP, Trans, SupCom, Misc));
                txtAddCPP.Text = value2.ToString("0.00");

                refresh();
            }
            else
            {
                txtAddTotalCost.Text = "";
                txtAddCPP.Text = "";
                MessageBox.Show("You need to fill all the values","Message");
            }
        }