private void Click_btnUpdate() { string strVal = ValidationMethot(); using (TransactionScope scope1 = new TransactionScope(TransactionScopeOption.Required)) { try { if (strVal == "") { this.oOrder.CustomerID = Int32.Parse(cmbCustomer.SelectedValue.ToString()); this.oOrder.EstimatedTotalProductionTime = Int32.Parse(lblTotalProductionTime.Content.ToString()); //if (txtTutar.Text != "") //{ // this.oOrder.TotalCost = decimal.Parse(txtTutar.Text); //} this.oOrder.DateOfDelivery = dpDateOfDelivery.SelectedDate.Value; this.oOrder.OrderStatus = (BLL.Enumarations.OrderStatus)Int32.Parse((cmbOrderStatus.SelectedItem as ComboBoxItem).Tag.ToString()); this.oOrder.Products = ""; foreach (BLL.Product item in this.oProductList) { this.oOrder.Products += "," + item.ID.ToString() + ""; } if (oProductList.Count > 0) { this.oOrder.Products += ","; } this.oOrder.State = BLL.Enumarations.State.Aktif; int firstResult = oOrder.Save(); if (firstResult == 0) { if (oProductList.Count == 0) { MessageBox.Show("Siparişte en az 1 adet yay olmalıdır."); return; } BLL.Order.DeleteOrderDetail(this.OID); foreach (BLL.Product item in dgOrderProduct.Items) { int secondResult = BLL.Order.SaveOrderDetail(this.OID, item.ID, item.OrderCount, item.UsedStockCountColored, item.UsedStockCountNonColored, item.ProductionCount, item.CColor.ID, item.CurrentPackageType, item.CurrentOPStatus); if (secondResult == 0) { // MessageBox.Show("İşlem başarılı"); this.oOrder.OrderStatus = BLL.Enumarations.OrderStatus.İmalataHazır; cmbOrderStatus.SelectedIndex = 0; cmbOrderStatus.Foreground = Brushes.Red; this.oOrder.Save(); } } MessageBox.Show("İşlem başarılı"); (((Start)((Grid)(((TabControl)(((TabItem)((Grid)((Grid)(this.Parent)).Parent).Parent).Parent)).Parent)).Parent)).GrdContentSearchOrder.Visibility = Visibility.Hidden; (((Start)((Grid)(((TabControl)(((TabItem)((Grid)((Grid)(this.Parent)).Parent).Parent).Parent)).Parent)).Parent)).GrdContentAddOrder.Visibility = Visibility.Hidden; (((Start)((Grid)(((TabControl)(((TabItem)((Grid)((Grid)(this.Parent)).Parent).Parent).Parent)).Parent)).Parent)).GrdContentOrderDetail.Visibility = Visibility.Visible; Ozyaysan.UserControls.UCOrderDetail oWindowsOrderDetail = new UserControls.UCOrderDetail(oOrder.ID); (((Start)((Grid)(((TabControl)(((TabItem)((Grid)((Grid)(this.Parent)).Parent).Parent).Parent)).Parent)).Parent)).GrdContentOrderDetail.Children.Add(oWindowsOrderDetail); (((Start)((Grid)(((TabControl)(((TabItem)((Grid)((Grid)(this.Parent)).Parent).Parent).Parent)).Parent)).Parent)).GrdContentOrderDetail.Children.RemoveAt(0); } scope1.Complete(); } else { MessageBox.Show(strVal); } } catch (System.Data.SqlClient.SqlException Exp) { MessageBox.Show("Sql Hatası oluştu : " + Exp.Message); } catch (Exception Exp) { MessageBox.Show("Hata oluştu : " + Exp.Message); } } }
private void UpdateGeneralOrderStatus(int Status) { BLL.Order oOrder = new BLL.Order(this.OID, BLL.Enumarations.State.Aktif); if (dtDetailedOrder.Rows.Count == 1) { oOrder.OrderStatus = (BLL.Enumarations.OrderStatus)Status; if (oOrder.Save() == 0) { MessageBox.Show("İşlem başarılı"); this.Close(); } else { MessageBox.Show("Kayıt işlemi sırasında bir hata oluştu"); } } else if (dtDetailedOrder.Rows.Count > 1) { switch (Status) { case 3: //boyahane if (!IsExistSmallerStatus((int)BLL.Enumarations.OrderStatus.Boyahanede)) { oOrder.OrderStatus = BLL.Enumarations.OrderStatus.Boyahanede; } break; case 4: //boyanıyor if (!IsExistSmallerStatus((int)BLL.Enumarations.OrderStatus.Boyanıyor)) { oOrder.OrderStatus = BLL.Enumarations.OrderStatus.Boyanıyor; } break; case 5: //hazır if (!IsExistSmallerStatus((int)BLL.Enumarations.OrderStatus.Hazir)) { oOrder.OrderStatus = BLL.Enumarations.OrderStatus.Hazir; } break; case 6: //gönderildi if (!IsExistSmallerStatus((int)BLL.Enumarations.OrderStatus.Gonderildi)) { oOrder.OrderStatus = BLL.Enumarations.OrderStatus.Gonderildi; } break; default: break; } if (oOrder.Save() == 0) { MessageBox.Show("İşlem başarılı"); this.Close(); } else { MessageBox.Show("Kayıt işlemi sırasında bir hata oluştu"); } } }
private void Click_btnSave() { using (TransactionScope scope1 = new TransactionScope(TransactionScopeOption.Required)) { try { string strVal = ValidationMethot(); if (strVal == "") { BLL.Order oOrder = new BLL.Order(); oOrder.CustomerID = Int32.Parse(cmbCustomer.SelectedValue.ToString()); oOrder.DateOfDelivery = dpDateOfDelivery.SelectedDate.Value; string a = String.Format("{0:d/M/yyyy HH:mm:ss}", oOrder.DateOfDelivery); oOrder.DateOfDelivery2 = a; oOrder.MinState = BLL.Enumarations.State.Aktif; oOrder.OrderStatus = BLL.Enumarations.OrderStatus.İmalataHazır; oOrder.State = BLL.Enumarations.State.Aktif; oOrder.Products = ""; foreach (BLL.Product item in dgOrderProduct.Items) { oOrder.Products += "," + item.ID.ToString() + ""; } oOrder.Products += ","; oOrder.EstimatedTotalProductionTime = Int32.Parse(lblProductionTime.Content.ToString()); //if (txtTutar.Text!="") //{ // oOrder.TotalCost = decimal.Parse(txtTutar.Text); //} int firstResult = -1; int secondResult = -1; firstResult = oOrder.Save(); if (firstResult == 0) { foreach (BLL.Product item in dgOrderProduct.Items) { secondResult = BLL.Order.SaveOrderDetail(oOrder.ID, item.ID, item.OrderCount, item.UsedStockCountColored, item.UsedStockCountNonColored, item.ProductionCount, item.CColor.ID, item.CurrentPackageType, item.CurrentOPStatus); if (secondResult == 0) { (((Start)((Grid)(((TabControl)(((TabItem)((Grid)((Grid)(this.Parent)).Parent).Parent).Parent)).Parent)).Parent)).GrdContentSearchOrder.Visibility = Visibility.Hidden; (((Start)((Grid)(((TabControl)(((TabItem)((Grid)((Grid)(this.Parent)).Parent).Parent).Parent)).Parent)).Parent)).GrdContentAddOrder.Visibility = Visibility.Hidden; (((Start)((Grid)(((TabControl)(((TabItem)((Grid)((Grid)(this.Parent)).Parent).Parent).Parent)).Parent)).Parent)).GrdContentOrderDetail.Visibility = Visibility.Visible; Ozyaysan.UserControls.UCOrderDetail oWindowsOrderDetail = new UserControls.UCOrderDetail(oOrder.ID); (((Start)((Grid)(((TabControl)(((TabItem)((Grid)((Grid)(this.Parent)).Parent).Parent).Parent)).Parent)).Parent)).GrdContentOrderDetail.Children.Clear(); (((Start)((Grid)(((TabControl)(((TabItem)((Grid)((Grid)(this.Parent)).Parent).Parent).Parent)).Parent)).Parent)).GrdContentOrderDetail.Children.Add(oWindowsOrderDetail); } } } MessageBox.Show("İşlem Başarili"); } else { MessageBox.Show(strVal); } scope1.Complete(); } catch (System.Data.SqlClient.SqlException Exp) { MessageBox.Show("Sql Hatası oluştu : " + Exp.Message); } catch (Exception Exp) { MessageBox.Show("Hata oluştu : " + Exp.Message); } } #endregion }