コード例 #1
0
 private void lstSugesstions_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     txtSparePartCode.TextChanged -= new TextChangedEventHandler(txtSparePartCode_TextChanged);
     if (lstSugesstions.SelectedValue != null)
     {
         txtSparePartCode.Text = (lstSugesstions.SelectedItem as DDBinding).Name;
         selectedPart = data.GetAll<SPARE_RATE>(s => s.SPARE_PART_ID == Convert.ToInt32(lstSugesstions.SelectedValue)).Select(s => s).FirstOrDefault();               
     }
     lstSugesstions.Visibility = Visibility.Collapsed;
     txtSparePartCode.TextChanged += new TextChangedEventHandler(txtSparePartCode_TextChanged);
 }
コード例 #2
0
 partial void DeleteSPARE_RATE(SPARE_RATE instance);
コード例 #3
0
 partial void UpdateSPARE_RATE(SPARE_RATE instance);
コード例 #4
0
 partial void InsertSPARE_RATE(SPARE_RATE instance);
コード例 #5
0
		private void detach_SPARE_RATEs(SPARE_RATE entity)
		{
			this.SendPropertyChanging();
			entity.SUPPLIER = null;
		}
コード例 #6
0
		private void attach_SPARE_RATEs(SPARE_RATE entity)
		{
			this.SendPropertyChanging();
			entity.SPARE_PART = this;
		}
コード例 #7
0
ファイル: AddSparesView.xaml.cs プロジェクト: qq5013/TMS-1
        private void btnAddSpare_Click(object sender, RoutedEventArgs e)
        {
            if (cmbSupplier.Text != string.Empty && txtSparePartCode.Text != string.Empty && txtPartDescription.Text != string.Empty && txtSpareUnitPrice.Text != string.Empty && txtMinLevel.Text != string.Empty)
            {
                SPARE_RATE rates = new SPARE_RATE();
                var result = data.GetAll<SPARE_PART>(s => s.SPARE_PART_CODE.ToUpper().Equals(txtSparePartCode.Text.ToUpper())).FirstOrDefault();
                if (result == null)
                {
                    rates.SPARE_RATE_VALUE = Convert.ToDecimal(txtSpareUnitPrice.Text);
                    rates.SUPPLIER_ID = Convert.ToInt32(cmbSupplier.SelectedValue);
                    rates.SPARE_PART = new SPARE_PART()
                    {
                        SPARE_PART_CODE = txtSparePartCode.Text,
                        SPARE_PART_DESCRIPTION = txtPartDescription.Text,
                        SPARE_MINLEVEL = Convert.ToInt32(txtMinLevel.Text),
                        SPARE_BIN_NO = txtSpareBinNumber.Text,
                        SPARE_STATUS = Convert.ToInt32(cmbSpareStatus.SelectedValue)
                    };
                    data.Insert<SPARE_RATE>(rates);
                }
                else
                {
                    var currentSpareRate = result.SPARE_RATEs.Where(s => s.SUPPLIER_ID == Convert.ToInt32(cmbSupplier.SelectedValue)).Select(s => s).FirstOrDefault();
                    if (currentSpareRate != null && Convert.ToInt32(cmbSupplier.SelectedValue) == currentSpareRate.SUPPLIER_ID)
                    {
                        var updateMsgRes = MessageBox.Show("Unit Cost value will be updated from " + currentSpareRate.SPARE_RATE_VALUE + " to " + txtSpareUnitPrice.Text, "Warning", MessageBoxButton.YesNo, MessageBoxImage.Warning);
                        if (updateMsgRes.Equals(MessageBoxResult.Yes))
                        {
                            currentSpareRate.SPARE_RATE_VALUE = Convert.ToDecimal(txtSpareUnitPrice.Text);
                            data.Update<SPARE_RATE>();
                            MessageBox.Show("Spare Updated Successfully.");
                            Common.ClearAllControls<TextBox>(addSpares, 1);
                            Common.ClearAllControls<ComboBox>(addSpares);
                        }
                        return;
                    }
                    else
                    {
                        rates.SUPPLIER_ID = Convert.ToInt32(cmbSupplier.SelectedValue);
                        rates.SPARE_PART_ID = result.SPARE_PART_ID;
                        rates.SPARE_RATE_VALUE = Convert.ToDecimal(txtSpareUnitPrice.Text);
                        data.Insert<SPARE_RATE>(rates);
                    }
                }
            }
            else
            {
                MessageBox.Show("Please Fill All the mandatory fields");
                return;
            }

            MessageBoxResult MsgResult = MessageBox.Show("Verify If You have Chosen correct Supplier Becuase Supplier Information Will not be Edited in Future. You want to Proceed? ", "Warning", MessageBoxButton.YesNo, MessageBoxImage.Warning);

            if (MsgResult.Equals(MessageBoxResult.Yes))
            {
                BindSpares();
                MessageBox.Show("Spare Added Successfully");
                Common.ClearAllControls<TextBox>(addSpares, 1);
                Common.ClearAllControls<ComboBox>(addSpares);
            }
        }