Ejemplo n.º 1
0
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            string strVal = ValidationMethot();

            if (strVal == "")
            {
                oProduct.Name            = txtCode.Text;
                oProduct.Code            = txtCode.Text;
                oProduct.ExtraCode1      = txtExtraKod1.Text;
                oProduct.ExtraCode2      = txtExtraKod2.Text;
                oProduct.ExtraCode3      = txtExtraKod3.Text;
                oProduct.ExtraCode4      = txtExtraKod4.Text;
                oProduct.TecniquePicture = "None.png";
                foreach (TempPicture item in PictureList)
                {
                    switch (item.PictureIndex)
                    {
                    case 1:
                        oProduct.Picture1 = item.SavedFileName;
                        break;

                    case 2:
                        oProduct.Picture2 = item.SavedFileName;
                        break;

                    case 3:
                        oProduct.Picture3 = item.SavedFileName;
                        break;

                    case 4:
                        oProduct.Picture4 = item.SavedFileName;
                        break;

                    case 5:
                        oProduct.TecniquePicture = item.SavedFileName;
                        break;

                    default:
                        break;
                    }
                }
                oProduct.Diameter     = float.Parse(txtDiameter.Text);
                oProduct.WireDiameter = float.Parse(txtWireDiameter.Text);
                oProduct.Name         = txtCode.Text;
                // oProduct.NumberOfForm = Int32.Parse(txtNumForms.Text);
                oProduct.NumberOfTurns = Int32.Parse(txtNumTurns.Text);
                oProduct.RawMaterialsCharacteristic = txtRawMatarialCharacters.Text;
                oProduct.State = BLL.Enumarations.State.Aktif;
                oProduct.StraighteningLength = float.Parse(txtStraighteningLength.Text);
                oProduct.Price  = 0;// kaldırıldı
                oProduct.Weight = float.Parse(txtWeight.Text);
                BLL.Category oCategory = new BLL.Category();
                oProduct.Category    = oCategory;
                oProduct.Category.ID = Int32.Parse(cmbCategory.SelectedValue.ToString());
                //if (oProduct.Category.ID == 1)
                //{
                //    oProduct.HatveArasi = Int32.Parse(txtHatve.Text);
                //    oProduct.ToplamBoy = Int32.Parse(txtToplamBoy.Text);
                //}
                //else if (oProduct.Category.ID == 2)
                //{
                //    oProduct.KancaArasi = Int32.Parse(txtKancaArasi.Text);
                //    oProduct.Ictenice = Int32.Parse(txtIctenice.Text);
                //    oProduct.KancaYonu = txtkancaYon.Text;
                //}
                // oProduct.Stock = Int32.Parse(txtStock.Text);
                int nResult = oProduct.Save();
                if (nResult == 0)
                {
                    foreach (TempPicture item in PictureList)
                    {
                        if (item.IsTecniqueImage)
                        {
                            CopyTecniqueImageToSharedImageFolder(item.FilePath, item.FileName, item.SavedFileName);
                        }
                        else
                        {
                            CopyImageToSharedImageFolder(item.FilePath, item.FileName, item.SavedFileName);
                        }

                        LoadDetail();
                    }
                    MessageBox.Show("İşlem başarılı");
                }
                else if (nResult == 3)
                {
                    MessageBox.Show("Bu OEM kodu daha önce kullanılmış");
                }
                else
                {
                    MessageBox.Show("Kayıt işlemi esnasında bir hata oluştu.");
                }
            }
            else
            {
                MessageBox.Show(strVal);
            }
        }
Ejemplo n.º 2
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                string strVal = ValidationMethot();
                if (strVal == "")
                {
                    BLL.Product oProduct = new BLL.Product();
                    if (this.PID == 0)
                    {
                        oProduct.ID = 0;
                    }
                    else
                    {
                        oProduct.ID = PID;
                    }
                    oProduct.Code            = txtCode.Text;
                    oProduct.ExtraCode1      = txtExtraKod1.Text;
                    oProduct.ExtraCode2      = txtExtraKod2.Text;
                    oProduct.ExtraCode3      = txtExtraKod3.Text;
                    oProduct.ExtraCode4      = txtExtraKod4.Text;
                    oProduct.Picture1        = "None.png";
                    oProduct.Picture2        = "None.png";
                    oProduct.Picture3        = "None.png";
                    oProduct.Picture4        = "None.png";
                    oProduct.TecniquePicture = "None.png";
                    foreach (TempPicture item in PictureList)
                    {
                        switch (item.PictureIndex)
                        {
                        case 1:
                            oProduct.Picture1 = item.SavedFileName;
                            break;

                        case 2:
                            oProduct.Picture2 = item.SavedFileName;
                            break;

                        case 3:
                            oProduct.Picture3 = item.SavedFileName;
                            break;

                        case 4:
                            oProduct.Picture4 = item.SavedFileName;
                            break;

                        case 5:
                            oProduct.TecniquePicture = item.SavedFileName;
                            break;

                        default:
                            break;
                        }
                    }
                    oProduct.Diameter     = float.Parse((txtDiameter.Text.Trim() == "")?0.ToString():txtDiameter.Text.Trim());
                    oProduct.WireDiameter = float.Parse((txtWireDiameter.Text.Trim() == "") ? 0.ToString() : txtWireDiameter.Text.Trim());
                    oProduct.Name         = txtCode.Text;
                    //oProduct.NumberOfForm = Int32.Parse(txtNumForms.Text);
                    oProduct.NumberOfTurns = Int32.Parse((txtNumTurns.Text.Trim() == "") ? 0.ToString() : txtNumTurns.Text.Trim());
                    oProduct.RawMaterialsCharacteristic = txtRawMatarialCharacters.Text;
                    oProduct.State = BLL.Enumarations.State.Aktif;
                    oProduct.StraighteningLength = float.Parse((txtStraighteningLength.Text.Trim() == "") ? 0.ToString() : txtStraighteningLength.Text.Trim());
                    oProduct.Price  = 0;// kaldırıldı
                    oProduct.Weight = float.Parse((txtWeight.Text.Trim() == "") ? 0.ToString() : txtWeight.Text.Trim());
                    BLL.Category oCategory = new BLL.Category();
                    oProduct.Category    = oCategory;
                    oProduct.Category.ID = Int32.Parse(cmbCategory.SelectedValue.ToString());
                    //if ( oProduct.Category.ID==1)
                    //{
                    //    oProduct.HatveArasi = Int32.Parse(txtHatve.Text);
                    //    oProduct.ToplamBoy = Int32.Parse(txtToplamBoy.Text);
                    //}
                    //else if (oProduct.Category.ID==2)
                    //{
                    //    oProduct.KancaArasi = Int32.Parse(txtKancaArasi.Text);
                    //    oProduct.Ictenice = Int32.Parse(txtIctenice.Text);
                    //    oProduct.KancaYonu = txtkancaYon.Text;
                    //}
                    // oProduct.Stock = Int32.Parse(txtStock.Text);
                    int nResult = oProduct.Save();
                    if (nResult == 0)
                    {
                        foreach (TempPicture item in PictureList)
                        {
                            if (item.IsTecniqueImage)
                            {
                                CopyTecniqueImageToSharedImageFolder(item.FilePath, item.FileName, item.SavedFileName);
                            }
                            else
                            {
                                CopyImageToSharedImageFolder(item.FilePath, item.FileName, item.SavedFileName);
                            }
                        }

                        MessageBox.Show("Yeni yay ekleme işlemi başarılı bir şekilde tamamlandı.Şimdi yay için üretim aşaması ekleme formuna yönlendiriliyorsunuz.");
                        var window = new W_AddProductionPhase(oProduct.ID)
                        {
                            Title                 = "Üretim Aşaması Ekle",
                            ShowInTaskbar         = false,
                            Topmost               = true,
                            ResizeMode            = ResizeMode.CanMinimize,
                            Owner                 = Application.Current.MainWindow,
                            WindowStartupLocation = WindowStartupLocation.CenterScreen
                        };
                        if (window.ShowDialog() == false)
                        {
                            (((Start)((Grid)(((TabControl)(((TabItem)((Grid)((Grid)(this.Parent)).Parent).Parent).Parent)).Parent)).Parent)).GrdContentSearchProduct.Visibility = Visibility.Hidden;
                            (((Start)((Grid)(((TabControl)(((TabItem)((Grid)((Grid)(this.Parent)).Parent).Parent).Parent)).Parent)).Parent)).GrdContentAddProduct.Visibility    = Visibility.Hidden;
                            (((Start)((Grid)(((TabControl)(((TabItem)((Grid)((Grid)(this.Parent)).Parent).Parent).Parent)).Parent)).Parent)).GrdContentProductDetail.Visibility = Visibility.Visible;
                            Ozyaysan.UserControls.UCProductDetail oWindowsProductDetail = new UserControls.UCProductDetail(oProduct.ID);
                            (((Start)((Grid)(((TabControl)(((TabItem)((Grid)((Grid)(this.Parent)).Parent).Parent).Parent)).Parent)).Parent)).GrdContentProductDetail.Children.Clear();
                            (((Start)((Grid)(((TabControl)(((TabItem)((Grid)((Grid)(this.Parent)).Parent).Parent).Parent)).Parent)).Parent)).GrdContentProductDetail.Children.Add(oWindowsProductDetail);
                        }
                    }
                    else if (nResult == 3)
                    {
                        MessageBox.Show("Bu OEM kodlu yay daha önce eklenmiş !!");
                    }
                    else
                    {
                        MessageBox.Show("Kayıt esnasında bir hata oluştu !!");
                    }
                }
                else
                {
                    MessageBox.Show(strVal);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }