private async void NewSupplierBT_Click(object sender, RoutedEventArgs e) { if (FilterGrid.Opacity != 0) { FilterGrid.BeginStoryboard((Storyboard)Application.Current.TryFindResource("FadeInGrid")); await Task.Delay(100); } //From grid animation if (FormGrid.Opacity == 0) { FormGrid.BeginStoryboard((Storyboard)Application.Current.TryFindResource("PopUpGrid")); SuppSocialNameTX.Focus(); SaveBT.IsEnabled = true; } else if (SuppSocialNameTX.Text.Length == 0) { FormGrid.BeginStoryboard((Storyboard)Application.Current.TryFindResource("FadeInGrid")); ResetForm(); } //Clear supplier values if (SuppSocialNameTX.Text.Length > 0) { ResetForm(); } }
private async void Delete_Click(object sender, RoutedEventArgs e) { if (FormGrid.Opacity != 0) { ResetForm(); FormGrid.BeginStoryboard((Storyboard)Application.Current.TryFindResource("FadeInGrid")); } //Get button control Button Control = (Button)sender; //Get User information var Product = NovaAPI.APIProdructs.products.Find(x => x.id == Control.Tag.ToString()); if (MessageBox.Show($"A continuación se eliminara el producto '{Product.name}'{Environment.NewLine}¿Desea continuar?", "Eliminar producto", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { var Data = new NovaAPI.APIProdructs.ProductClass(); Data.id = Product.id; //Delete user string requestData = JsonConvert.SerializeObject(Data); bool response = await NovaAPI.APIProdructs.GetValues("3", DataConfig.LocalAPI, requestData); if (response) { NovaAPI.APIProdructs.products.Remove(Product); ProductsGrid.Items.Refresh(); } else { MessageBox.Show($"Error al eliminar el producto, INFO: {Environment.NewLine}{NovaAPI.APIProdructs.Message}"); } } }
private void EditRol_Click(object sender, RoutedEventArgs e) { //Get button control Button Control = (Button)sender; string rolid = NovaAPI.APIRoles.userrols.Find(x => x.rolid == Control.Tag.ToString()).rolid; if (rolid == "1") { MessageBox.Show("No se puede editar el rol de administrador del sistema"); return; } if (FormGrid.Opacity == 0) { FormGrid.BeginStoryboard((Storyboard)Application.Current.TryFindResource("PopUpGrid")); } //Set rol information to controls RolNameTX.Text = NovaAPI.APIRoles.userrols.Find(x => x.rolid == Control.Tag.ToString()).rolname; RolDescriptTX.Text = NovaAPI.APIRoles.userrols.Find(x => x.rolid == Control.Tag.ToString()).roldescription; EditPermBT.IsEnabled = true; //Set selected rol id index for edition save SelectedIndex = Control.Tag.ToString(); //Focus editable rol RolNameTX.Focus(); SaveBT.IsEnabled = true; }
//Open client form for edit private void Edit_Click(object sender, RoutedEventArgs e) { //Hide filter if (FilterGrid.Opacity != 0) { FilterGrid.BeginStoryboard((Storyboard)Application.Current.TryFindResource("FadeInGrid")); } //Get button control Button Control = (Button)sender; var Client = NovaAPI.APIClient.clients.Find(x => x.id == Control.Tag.ToString()); if (FormGrid.Opacity == 0) { FormGrid.BeginStoryboard((Storyboard)Application.Current.TryFindResource("PopUpGrid")); } //Set supplier information to controls ClientNameTX.Text = Client.name; ClientIDTX.Text = Client.documentid; ClientTypeCB.SelectedIndex = Convert.ToInt32(Client.type); ClientPhoneTX.Text = Client.phone; ClientCelphoneTX.Text = Client.celphone; ClientAddressTX.Text = Client.address; ClientMailTX.Text = Client.mail; ClientCreditCB.IsChecked = Client.cancredit == "0" ? false : true; //Set selected supplier id index for edition save SelectedIndex = Control.Tag.ToString(); //Focus editable rol ClientNameTX.Focus(); SaveBT.IsEnabled = true; }
//Refresh Branch list private void RefreshBT_Click(object sender, RoutedEventArgs e) { FormGrid.BeginStoryboard((Storyboard)Application.Current.TryFindResource("FadeInGrid")); ResetForm(); LoadData(); SaveBT.IsEnabled = false; }
//Permissions Selected private void TabControl_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (e.Source is TabControl) { if (PermissionsTab.IsSelected) { //Get rol index string selection = SelectedIndex == "" ? "1" : SelectedIndex; PermissionsGrid.IsEnabled = selection == "1" ? false : true; //Set disabled permission edit on administrator rol PermissionsSaveBT.IsEnabled = selection == "1" ? false : true; //Reset rol status form PermissionsSaveBT.Background = (SolidColorBrush)Application.Current.TryFindResource("ConfigHeader"); FormGrid.BeginStoryboard((Storyboard)Application.Current.TryFindResource("FadeInGrid")); ResetForm(); RolID = selection; var Data = NovaAPI.APIRoles.userrols.Find(x => x.rolid == selection).RolData; //Load permissions on selected rol or null rol PermissionsGrid.ItemsSource = Data; PermissionsGrid.Items.Refresh(); //Set rol name title LabelTitle.Content = NovaAPI.APIRoles.userrols.Find(x => x.rolid == selection).rolname; } } }
private void RefreshBT_Click(object sender, RoutedEventArgs e) { if (FormGrid.Opacity == 1) { FormGrid.BeginStoryboard((Storyboard)Application.Current.TryFindResource("FadeInGrid")); } ResetForm(); LoadData(); }
//Edit product button toggle private void Edit_Click(object sender, RoutedEventArgs e) { //Get button control Button Control = (Button)sender; if (FilterGrid.Opacity != 0) { FilterGrid.BeginStoryboard((Storyboard)Application.Current.TryFindResource("FadeInGrid")); } var ProductData = NovaAPI.APIProdructs.products.Find(x => x.id == Control.Tag.ToString()); if (FormGrid.Opacity == 0) { FormGrid.BeginStoryboard((Storyboard)Application.Current.TryFindResource("PopUpGrid")); } //Set popup name PopUpProductName.Content = ProductData.name; PopUpProductValue.Content = string.Format("Precio venta general: {0:C0}", Convert.ToInt32(ProductData.sellprice)); //Set product information to controls ProductCodeTX.Text = ProductData.code; ProductNameTX.Text = ProductData.name; ProductCatCB.SelectedItem = NovaAPI.APICategory.category.Find(x => x.id == ProductData.category); ProductCostTX.Number = Convert.ToInt32(ProductData.costprice); ProductPriceTX.Number = Convert.ToInt32(ProductData.sellprice); ProductTypeCB.SelectedIndex = Convert.ToInt32(ProductData.unity_type); MinStockTX.Text = ProductData.minstock; MaxStockTX.Text = ProductData.maxstock; //Set taxes if (ProductData.iva == "0" && ProductData.iac == "0" && ProductData.iva5 == "0") { TaxNoneRB.IsChecked = true; } else { TaxIvaRB.IsChecked = ProductData.iva == "1" ? true : false; TaxIva5RB.IsChecked = ProductData.iva5 == "1" ? true : false; TaxIacRB.IsChecked = ProductData.iac == "1" ? true : false; } //Set selected product id index for edition save ProductSelectIndex = Control.Tag.ToString(); //Focus editable product ProductCodeTX.Focus(); SaveProductBT.IsEnabled = true; PricesBT.IsEnabled = true; }
//Users action buttons private void Edit_Click(object sender, RoutedEventArgs e) { //Get button control Button Control = (Button)sender; //Set user information to controls var UserData = NovaAPI.APIUsers.users.Find(x => x.id == Control.Tag.ToString()); if (UserData.id == "1") { MessageBox.Show("No se puede modificar el usuario de administrador del sistema."); return; } if (FormGrid.Opacity == 0) { FormGrid.BeginStoryboard((Storyboard)Application.Current.TryFindResource("PopUpGrid")); } //User principal data UserNameTX.Text = UserData.name; UserRealTX.Text = UserData.realname; UserPassword.Password = UserData.name; //User rol and branch data UserRolCB.SelectedItem = NovaAPI.APIRoles.userrols.Find(x => x.rolid == UserData.rolid); UserBranchCB.SelectedItem = NovaAPI.APIBranch.branch.Find(x => x.id == UserData.branchid); //user status data UserStatusCB.IsChecked = UserData.status == "1" ? true : false; //Set photo //------------------------- //Set selected rol id index for edition save SelectedIndex = Control.Tag.ToString(); UserRolCB.Items.Refresh(); UserBranchCB.Items.Refresh(); //Focus editable rol UserNameTX.Focus(); SaveBT.IsEnabled = true; }
private async void DeleteBranch_Click(object sender, RoutedEventArgs e) { if (FormGrid.Opacity != 0) { ResetForm(); FormGrid.BeginStoryboard((Storyboard)Application.Current.TryFindResource("FadeInGrid")); } //Get button control Button Control = (Button)sender; int branchpoints = Convert.ToInt32(NovaAPI.APIBranch.branch.Find(x => x.id == Control.Tag.ToString()).boxes); if (branchpoints > 0) { MessageBox.Show("No se puede eliminar una sucursal con puntos de venta vinculados" + Environment.NewLine + "Por favor desvincule los puntos de venta antes de eliminar la sucursal"); return; } //Get Branch information string BranchName = NovaAPI.APIBranch.branch.Find(x => x.id == Control.Tag.ToString()).name; if (MessageBox.Show($"A continuación se eliminara la sucursal '{BranchName}{Environment.NewLine}¿Desea continuar?", "Eliminar sucursal", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { var Data = new NovaAPI.APIBranch.BranchClass(); Data.id = Control.Tag.ToString(); //Delete rol string requestData = JsonConvert.SerializeObject(Data); bool response = await NovaAPI.APIBranch.GetValues("3", DataConfig.LocalAPI, requestData); if (response) { NovaAPI.APIBranch.branch.Remove(NovaAPI.APIBranch.branch.Find(x => x.id == Control.Tag.ToString())); BranchGrid.Items.Refresh(); } else { MessageBox.Show($"Error al eliminar la sucursal, INFO: {Environment.NewLine}{NovaAPI.APIRoles.Message}"); } } }
//New user action private void NewUserBT_Click(object sender, RoutedEventArgs e) { //From grid animation if (FormGrid.Opacity == 0) { FormGrid.BeginStoryboard((Storyboard)Application.Current.TryFindResource("PopUpGrid")); UserNameTX.Focus(); SaveBT.IsEnabled = true; } else if (UserNameTX.Text.Length == 0) { FormGrid.BeginStoryboard((Storyboard)Application.Current.TryFindResource("FadeInGrid")); ResetForm(); } //Clear branch values if (UserNameTX.Text.Length > 0) { ResetForm(); } }
//Refresh products data private void RefreshProducts_Click(object sender, RoutedEventArgs e) { if (FormGrid.Opacity == 1) { FormGrid.BeginStoryboard((Storyboard)Application.Current.TryFindResource("FadeInGrid")); } if (FilterGrid.Opacity == 1) { FilterGrid.BeginStoryboard((Storyboard)Application.Current.TryFindResource("FadeInGrid")); } TotalPages = 0; Pagination = 1; ResetForm(); LoadProducts(); NewProductBT.Focus(); }
private async void DeleteRol_Click(object sender, RoutedEventArgs e) { if (FormGrid.Opacity != 0) { ResetForm(); FormGrid.BeginStoryboard((Storyboard)Application.Current.TryFindResource("FadeInGrid")); } //Get button control Button Control = (Button)sender; //Get rol information string rolname = NovaAPI.APIRoles.userrols.Find(x => x.rolid == Control.Tag.ToString()).rolname; string rolid = NovaAPI.APIRoles.userrols.Find(x => x.rolid == Control.Tag.ToString()).rolid; if (rolid == "1") { MessageBox.Show("No se puede eliminar el rol de administrador del sistema"); return; } if (MessageBox.Show($"A continuación se eliminara el rol '{rolname}{Environment.NewLine}¿Desea continuar?", "Eliminar rol", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { var Data = new rolData(); Data.id = rolid; //Delete rol string requestData = JsonConvert.SerializeObject(Data); bool response = await NovaAPI.APIRoles.GetValues("3", DataConfig.LocalAPI, requestData); if (response) { NovaAPI.APIRoles.userrols.Remove(NovaAPI.APIRoles.userrols.Find(x => x.rolid == rolid)); RolGrid.Items.Refresh(); } else { MessageBox.Show($"Error al eliminar el rol, INFO: {Environment.NewLine}{NovaAPI.APIRoles.Message}"); } } }
//Clear all form data and selections private void ClearFormData() { if (FormGrid.Opacity != 0) { FormGrid.BeginStoryboard((Storyboard)Application.Current.TryFindResource("FadeInGrid")); } if (FilterGrid.Opacity != 0) { FilterGrid.BeginStoryboard((Storyboard)Application.Current.TryFindResource("FadeInGrid")); } FilterTX.Clear(); ClientNameTX.Clear(); ClientIDTX.Clear(); ClientPhoneTX.Clear(); ClientAddressTX.Clear(); ClientMailTX.Clear(); ClientCelphoneTX.Clear(); ClientTypeCB.SelectedIndex = 0; ClientCreditCB.IsChecked = true; SaveBT.IsEnabled = false; }
private async void FilterBT_Click(object sender, RoutedEventArgs e) { if (FormGrid.Opacity != 0) { FormGrid.BeginStoryboard((Storyboard)Application.Current.TryFindResource("FadeInGrid")); ResetForm(); await Task.Delay(100); } FilterTX.Clear(); if (FilterGrid.Opacity == 0) { FilterGrid.BeginStoryboard((Storyboard)Application.Current.TryFindResource("PopUpGrid")); FilterTX.Focus(); } else { FilterGrid.BeginStoryboard((Storyboard)Application.Current.TryFindResource("FadeInGrid")); } }
private void Edit_Click(object sender, RoutedEventArgs e) { //Hide filter if (FilterGrid.Opacity != 0) { FilterGrid.BeginStoryboard((Storyboard)Application.Current.TryFindResource("FadeInGrid")); } //Get button control Button Control = (Button)sender; var Supplier = NovaAPI.APISupplier.suppliers.Find(x => x.id == Control.Tag.ToString()); if (FormGrid.Opacity == 0) { FormGrid.BeginStoryboard((Storyboard)Application.Current.TryFindResource("PopUpGrid")); } //Set supplier information to controls SuppSocialNameTX.Text = Supplier.socialname; SuppComercialNameTX.Text = Supplier.comercialname; SuppidTypeCB.SelectedIndex = Convert.ToInt32(Supplier.idtype); SuppIDTX.Text = Supplier.documentid; SuppAddressTX.Text = Supplier.address; SuppPhoneTX.Text = Supplier.phone; SuppCelphoneTX.Text = Supplier.celphone; SuppEmailTX.Text = Supplier.mail; SuppContactTX.Text = Supplier.contact; SuppObvsTX.Text = Supplier.observation; StatusCB.IsChecked = Supplier.status == "1" ? true : false; //Set selected supplier id index for edition save SelectedIndex = Control.Tag.ToString(); //Focus editable rol SuppSocialNameTX.Focus(); SaveBT.IsEnabled = true; }
private void EditBranch_Click(object sender, RoutedEventArgs e) { //Get button control Button Control = (Button)sender; if (FormGrid.Opacity == 0) { FormGrid.BeginStoryboard((Storyboard)Application.Current.TryFindResource("PopUpGrid")); } //Set branch information to controls BranchNameTX.Text = NovaAPI.APIBranch.branch.Find(x => x.id == Control.Tag.ToString()).name; BranchAddTX.Text = NovaAPI.APIBranch.branch.Find(x => x.id == Control.Tag.ToString()).address; BranchPhoneTX.Text = NovaAPI.APIBranch.branch.Find(x => x.id == Control.Tag.ToString()).phone; //Set selected rol id index for edition save SelectedIndex = Control.Tag.ToString(); //Focus editable rol BranchNameTX.Focus(); SaveBT.IsEnabled = true; }
private async void SaveRolBT_Click(object sender, RoutedEventArgs e) { NewRolBT.Focus(); if (RolNameTX.Text.Length == 0 || RolNameTX.Text.Length < 5) { MessageBox.Show("El nombre del rol no puede estar en blanco o ser inferior a 5 caracteres"); RolNameTX.Focus(); return; } //Get rol parameters var Data = new rolData(); Data.id = SelectedIndex; Data.name = RolNameTX.Text; Data.description = RolDescriptTX.Text; //rol json data string requestData = JsonConvert.SerializeObject(Data); bool response; //Modify / Create request if (Data.id.Length > 0) { response = await NovaAPI.APIRoles.GetValues("2", DataConfig.LocalAPI, requestData); } else { response = await NovaAPI.APIRoles.GetValues("1", DataConfig.LocalAPI, requestData); } //Request response if (response) { if (Data.id.Length > 0) { //On role modified NovaAPI.APIRoles.userrols.Find(x => x.rolid == Data.id).rolname = Data.name; NovaAPI.APIRoles.userrols.Find(x => x.rolid == Data.id).roldescription = Data.description; RolGrid.Items.Refresh(); FormGrid.BeginStoryboard((Storyboard)Application.Current.TryFindResource("FadeInGrid")); ResetForm(); SaveBT.IsEnabled = false; } else { //On new rol created response var newRol = new NovaAPI.APIRoles.Rols(); newRol.rolname = Data.name; newRol.roldescription = Data.description; newRol.rolid = NovaAPI.APIRoles.LastID; newRol.usercount = "0"; //CREATE ROL DEFAULT PERMISSION DATA FormGrid.BeginStoryboard((Storyboard)Application.Current.TryFindResource("FadeInGrid")); ResetForm(); NovaAPI.APIRoles.userrols.Add(newRol); //Reload rol data LoadData(); SaveBT.IsEnabled = false; } } else { MessageBox.Show($"Error al crear el rol, INFO: {Environment.NewLine}{NovaAPI.APIRoles.Message}"); } }
//Supplier create / modify functions private async void SaveBT_Click(object sender, RoutedEventArgs e) { NewSupplierBT.Focus(); if (SuppSocialNameTX.Text.Length == 0 || SuppSocialNameTX.Text.Length < 5) { MessageBox.Show("La razón social no puede estar en blanco o ser inferior a 5 caracteres"); SuppSocialNameTX.Focus(); return; } else if (SuppIDTX.Text.Length == 0 || SuppIDTX.Text.Length < 5) { MessageBox.Show("El numero de identificacion no puede estar en blanco o ser inferior a 5 caracteres"); SuppIDTX.Focus(); return; } //Get/Set Supplier parameters var Data = new NovaAPI.APISupplier.SupplierClass(); Data.id = SelectedIndex; Data.socialname = SuppSocialNameTX.Text; Data.comercialname = SuppComercialNameTX.Text.Length == 0 ? SuppSocialNameTX.Text : SuppComercialNameTX.Text; Data.idtype = SuppidTypeCB.SelectedIndex.ToString(); Data.documentid = SuppIDTX.Text; Data.address = SuppAddressTX.Text; Data.mail = SuppEmailTX.Text; Data.phone = SuppPhoneTX.Text; Data.celphone = SuppCelphoneTX.Text; Data.contact = SuppContactTX.Text; Data.observation = SuppObvsTX.Text; Data.status = StatusCB.IsChecked == true ? "1" : "0"; //rol json data string requestData = JsonConvert.SerializeObject(Data); bool response; //Modify / Create request if (Data.id.Length > 0) { response = await NovaAPI.APISupplier.GetValues("2", DataConfig.LocalAPI, requestData); } else { response = await NovaAPI.APISupplier.GetValues("1", DataConfig.LocalAPI, requestData); } //Request response if (response) { if (Data.id.Length > 0) { //On supplier modified var SuppData = NovaAPI.APISupplier.suppliers.Find(x => x.id == Data.id); SuppData.socialname = Data.socialname; SuppData.comercialname = Data.comercialname; SuppData.idtype = Data.idtype; SuppData.documentid = Data.documentid; SuppData.address = Data.address; SuppData.mail = Data.mail; SuppData.phone = Data.phone; SuppData.celphone = Data.celphone; SuppData.contact = Data.contact; SuppData.observation = Data.observation; SuppData.status = Data.status; SuppliersGrid.Items.Refresh(); FormGrid.BeginStoryboard((Storyboard)Application.Current.TryFindResource("FadeInGrid")); ResetForm(); } else { //On new supplier created response var SuppData = new NovaAPI.APISupplier.SupplierClass(); SuppData.socialname = Data.socialname; SuppData.comercialname = Data.comercialname; SuppData.idtype = Data.idtype; SuppData.documentid = Data.documentid; SuppData.address = Data.address; SuppData.mail = Data.mail; SuppData.phone = Data.phone; SuppData.celphone = Data.celphone; SuppData.contact = Data.contact; SuppData.status = Data.status; SuppData.observation = Data.observation; SuppData.id = NovaAPI.APISupplier.LastID; FormGrid.BeginStoryboard((Storyboard)Application.Current.TryFindResource("FadeInGrid")); ResetForm(); NovaAPI.APISupplier.suppliers.Add(SuppData); //Reload rol data LoadData(); } } else { MessageBox.Show($"Error al crear el proveedor, INFO: {Environment.NewLine}{NovaAPI.APISupplier.Message}"); } }
/// <summary> /// Save user information /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void SaveBT_Click(object sender, RoutedEventArgs e) { NewUserBT.Focus(); if (UserNameTX.Text.Length == 0 || UserNameTX.Text.Length < 5) { MessageBox.Show("El nombre de usuario no puede estar en blanco o ser inferior a 5 caracteres"); UserNameTX.Focus(); return; } else if (UserPassword.Password.Length == 0 || UserPassword.Password.Length < 5) { MessageBox.Show("la contraseña no puede estar en blanco o ser inferior a 5 caracteres"); UserPassword.Focus(); return; } //Get/Set user parameters var Data = new NovaAPI.APIUsers.UsersClass(); Data.id = SelectedIndex; Data.name = UserNameTX.Text; Data.realname = UserRealTX.Text; Data.rolid = ((NovaAPI.APIRoles.Rols)UserRolCB.SelectedItem).rolid; Data.branchid = ((NovaAPI.APIBranch.BranchClass)UserBranchCB.SelectedItem).id; Data.status = UserStatusCB.IsChecked == true ? "1" : "0"; //Password logic if (CheckPassword.Visibility == Visibility.Visible) { Data.hash = GeneralFunctions.GenerateMD5(UserPassword.Password); } //rol json data string requestData = JsonConvert.SerializeObject(Data); bool response; //Modify / Create request if (Data.id.Length > 0) { response = await NovaAPI.APIUsers.GetValues("2", DataConfig.LocalAPI, requestData); } else { response = await NovaAPI.APIUsers.GetValues("1", DataConfig.LocalAPI, requestData); } //Request response if (response) { if (Data.id.Length > 0) { //On user modified var UserData = NovaAPI.APIUsers.users.Find(x => x.id == Data.id); UserData.name = Data.name; UserData.realname = Data.realname; UserData.branchid = Data.branchid; UserData.branchname = NovaAPI.APIBranch.branch.Find(x => x.id == Data.branchid).name; UserData.rolid = Data.rolid; UserData.rolname = NovaAPI.APIRoles.userrols.Find(x => x.rolid == Data.rolid).rolname; UserData.status = Data.status; UsersGrid.Items.Refresh(); FormGrid.BeginStoryboard((Storyboard)Application.Current.TryFindResource("FadeInGrid")); ResetForm(); } else { //On new user created response var UserData = new NovaAPI.APIUsers.UsersClass(); UserData.name = Data.name; UserData.realname = Data.realname; UserData.branchid = Data.branchid; UserData.branchname = NovaAPI.APIBranch.branch.Find(x => x.id == Data.branchid).name; UserData.rolid = Data.rolid; UserData.rolname = NovaAPI.APIRoles.userrols.Find(x => x.rolid == Data.rolid).rolname; UserData.status = Data.status; UserData.id = NovaAPI.APIUsers.LastID; FormGrid.BeginStoryboard((Storyboard)Application.Current.TryFindResource("FadeInGrid")); ResetForm(); NovaAPI.APIUsers.users.Add(UserData); //Reload rol data LoadData(); } } else { MessageBox.Show($"Error al crear el usuario, INFO: {Environment.NewLine}{NovaAPI.APIUsers.Message}"); } }
private async void SaveBT_Click(object sender, RoutedEventArgs e) { NewBranchBT.Focus(); if (BranchNameTX.Text.Length == 0 || BranchNameTX.Text.Length < 5) { MessageBox.Show("El nombre de la sucursal no puede estar en blanco o ser inferior a 5 caracteres"); BranchNameTX.Focus(); return; } //Get rol parameters var Data = new NovaAPI.APIBranch.BranchClass(); Data.id = SelectedIndex; Data.name = BranchNameTX.Text; Data.address = BranchAddTX.Text; Data.phone = BranchPhoneTX.Text; //rol json data string requestData = JsonConvert.SerializeObject(Data); bool response; //Modify / Create request if (Data.id.Length > 0) { response = await NovaAPI.APIBranch.GetValues("2", DataConfig.LocalAPI, requestData); } else { response = await NovaAPI.APIBranch.GetValues("1", DataConfig.LocalAPI, requestData); } //Request response if (response) { if (Data.id.Length > 0) { //On branch modified NovaAPI.APIBranch.branch.Find(x => x.id == Data.id).name = Data.name; NovaAPI.APIBranch.branch.Find(x => x.id == Data.id).address = Data.address; NovaAPI.APIBranch.branch.Find(x => x.id == Data.id).phone = Data.phone; BranchGrid.Items.Refresh(); FormGrid.BeginStoryboard((Storyboard)Application.Current.TryFindResource("FadeInGrid")); ResetForm(); SaveBT.IsEnabled = false; } else { //On new branch created response var branch = new NovaAPI.APIBranch.BranchClass(); branch.name = Data.name; branch.address = Data.address; branch.phone = Data.phone; branch.id = NovaAPI.APIRoles.LastID; branch.count = "0"; FormGrid.BeginStoryboard((Storyboard)Application.Current.TryFindResource("FadeInGrid")); ResetForm(); NovaAPI.APIBranch.branch.Add(branch); SaveBT.IsEnabled = false; //Reload rol data LoadData(); } } else { MessageBox.Show($"Error al crear la sucursal, INFO: {Environment.NewLine}{NovaAPI.APIRoles.Message}"); } }
private async void SaveProductBT_Click(object sender, RoutedEventArgs e) { NewProductBT.Focus(); if (ProductCodeTX.Text.Length == 0) { MessageBox.Show("El codigo del producto no puede estar en blanco"); ProductCodeTX.Focus(); return; } else if (ProductNameTX.Text.Length == 0 || ProductNameTX.Text.Length < 5) { MessageBox.Show("El nombre del producto no puede estar en blanco o ser inferior a 5 caracteres"); ProductNameTX.Focus(); return; } //Get/Set product parameters var Data = new NovaAPI.APIProdructs.ProductClass(); Data.id = ProductSelectIndex; Data.code = ProductCodeTX.Text; Data.name = ProductNameTX.Text; Data.category = ((NovaAPI.APICategory.CategoryClass)ProductCatCB.SelectedItem).id; Data.costprice = ProductCostTX.Number.ToString(); Data.sellprice = ProductPriceTX.Number.ToString(); Data.minstock = MinStockTX.Text; Data.maxstock = MaxStockTX.Text; Data.unity_type = ProductTypeCB.SelectedIndex.ToString(); Data.hproduct = H; Data.iva = TaxIvaRB.IsChecked == true ? "1" : "0"; Data.iac = TaxIacRB.IsChecked == true ? "1" : "0"; Data.iva5 = TaxIva5RB.IsChecked == true ? "1" : "0"; //rol json data string requestData = JsonConvert.SerializeObject(Data); bool response; //Modify / Create request if (Data.id.Length > 0) { response = await NovaAPI.APIProdructs.GetValues("2", DataConfig.LocalAPI, requestData); } else { response = await NovaAPI.APIProdructs.GetValues("1", DataConfig.LocalAPI, requestData); } //Request response if (response) { if (Data.id.Length > 0) { //On Product modified var ProductData = NovaAPI.APIProdructs.products.Find(x => x.id == Data.id); ProductData.code = Data.code; ProductData.name = Data.name; ProductData.category = Data.category; ProductData.costprice = Data.costprice; ProductData.sellprice = Data.sellprice; ProductData.minstock = Data.minstock; ProductData.maxstock = Data.maxstock; ProductData.unity_type = Data.unity_type; ProductData.iac = Data.iac; ProductData.iva5 = Data.iva5; ProductData.iva = Data.iva; ProductsGrid.Items.Refresh(); FormGrid.BeginStoryboard((Storyboard)Application.Current.TryFindResource("FadeInGrid")); ResetForm(); } else { //On new produict created response var ProductData = new NovaAPI.APIProdructs.ProductClass(); ProductData.code = Data.code; ProductData.name = Data.name; ProductData.category = Data.category; ProductData.costprice = Data.costprice; ProductData.sellprice = Data.sellprice; ProductData.minstock = Data.minstock; ProductData.maxstock = Data.maxstock; ProductData.iac = Data.iac; ProductData.iva5 = Data.iva5; ProductData.iva = Data.iva; ProductData.unity_type = Data.unity_type; ProductData.id = NovaAPI.APIProdructs.LastID; FormGrid.BeginStoryboard((Storyboard)Application.Current.TryFindResource("FadeInGrid")); ResetForm(); NovaAPI.APIProdructs.products.Add(ProductData); //reset pagination TotalPages = 0; Pagination = 1; //Reload product data LoadProducts(null, ProductData.code); } } else { MessageBox.Show($"Error al crear el producto, INFO: {Environment.NewLine}{NovaAPI.APIProdructs.Message}"); } }
//Save client private async void SaveBT_Click(object sender, RoutedEventArgs e) { NewClientBT.Focus(); if (ClientNameTX.Text.Length == 0) { MessageBox.Show("El nombre del cliente no puede estar en blanco"); ClientNameTX.Focus(); return; } //Get/Set client parameters var Data = new NovaAPI.APIClient.ClientClass(); Data.id = SelectedIndex; Data.name = ClientNameTX.Text; Data.type = ClientTypeCB.SelectedIndex.ToString(); Data.documentid = ClientIDTX.Text; Data.phone = ClientPhoneTX.Text; Data.celphone = ClientCelphoneTX.Text; Data.mail = ClientMailTX.Text; Data.address = ClientAddressTX.Text; Data.cancredit = ClientCreditCB.IsChecked == true ? "1" : "0"; //rol json data string requestData = JsonConvert.SerializeObject(Data); bool response; //Modify / Create request if (Data.id.Length > 0) { response = await NovaAPI.APIClient.GetValues("2", DataConfig.LocalAPI, requestData); } else { response = await NovaAPI.APIClient.GetValues("1", DataConfig.LocalAPI, requestData); } //Request response if (response) { if (Data.id.Length > 0) { //On client modified var ClientData = NovaAPI.APIClient.clients.Find(x => x.id == Data.id); ClientData.name = Data.name; ClientData.documentid = Data.documentid; ClientData.type = Data.type; ClientData.address = Data.address; ClientData.phone = Data.phone; ClientData.mail = Data.mail; ClientData.celphone = Data.celphone; ClientData.cancredit = Data.cancredit; ClientGrid.Items.Refresh(); FormGrid.BeginStoryboard((Storyboard)Application.Current.TryFindResource("FadeInGrid")); ClearFormData(); } else { //On new supplier created response var ClientData = new NovaAPI.APIClient.ClientClass(); ClientData.name = Data.name; ClientData.documentid = Data.documentid; ClientData.type = Data.type; ClientData.address = Data.address; ClientData.phone = Data.phone; ClientData.mail = Data.mail; ClientData.celphone = Data.celphone; ClientData.cancredit = Data.cancredit; ClientData.id = NovaAPI.APIClient.LastID; FormGrid.BeginStoryboard((Storyboard)Application.Current.TryFindResource("FadeInGrid")); ClearFormData(); NovaAPI.APIClient.clients.Add(ClientData); //Reload rol data LoadClients(); } } else { MessageBox.Show($"Error al crear el cliente, INFO: {Environment.NewLine}{NovaAPI.APIClient.Message}"); } }