public Security(App.Names AppName) { view = true; create = true; edit = true; delete = true; approve = true; annul = true; if (CurrentSession.UserRole == null) { db db = new entity.db(); security_role security_role = new security_role(); security_role.name = "Master"; security_role.is_active = true; security_role.is_master = true; db.security_role.Add(security_role); db.SaveChanges(); CurrentSession.UserRole = security_role; } if (CurrentSession.UserRole.is_master == false) { if (CurrentSession.Security_CurdList.Where(x => x.id_application == AppName).FirstOrDefault() != null) { security_curd security_curd = CurrentSession.Security_CurdList.Where(x => x.id_application == AppName).FirstOrDefault(); view = security_curd.can_read; create = security_curd.can_create; edit = security_curd.can_update; delete = security_curd.can_delete; approve = security_curd.can_approve; annul = security_curd.can_annul; } } }
private void Sales_Sync() { //entity.DebeHaber.Transactions Transactions = new entity.DebeHaber.Transactions(); entity.DebeHaber.Transactions SalesError = new entity.DebeHaber.Transactions(); //Loop through foreach (entity.sales_invoice sales_invoice in db.sales_invoice.Local.Where(x => x.IsSelected))// && x.is_accounted == false)) { entity.DebeHaber.Transactions Transactions = new entity.DebeHaber.Transactions(); Transactions.HashIntegration = RelationshipHash; entity.DebeHaber.Commercial_Invoice Sales = new entity.DebeHaber.Commercial_Invoice(); //Loads Data from Sales Sales.Fill_BySales(sales_invoice); ///Loop through Details. foreach (entity.sales_invoice_detail Detail in sales_invoice.sales_invoice_detail) { entity.DebeHaber.CommercialInvoice_Detail CommercialInvoice_Detail = new entity.DebeHaber.CommercialInvoice_Detail(); //Fill and Detail SalesDetail CommercialInvoice_Detail.Fill_BySales(Detail, db); Sales.CommercialInvoice_Detail.Add(CommercialInvoice_Detail); } //Loop through payments made. foreach (entity.payment_schedual schedual in sales_invoice.payment_schedual) { if (schedual.payment_detail != null && schedual.payment_detail.payment.is_accounted == false) { entity.DebeHaber.Payments Payments = new entity.DebeHaber.Payments(); //Fill and Add Payments Payments.FillPayments(schedual); Sales.Payments.Add(Payments); //This will make the Sales Invoice hide from the next load. schedual.payment_detail.payment.is_accounted = true; } } Transactions.Commercial_Invoice.Add(Sales); try { var Sales_Json = new JavaScriptSerializer().Serialize(Transactions); Send2API(Sales_Json); sales_invoice.is_accounted = true; } catch (Exception) { SalesError.Commercial_Invoice.Add(Sales); sales_invoice.is_accounted = false; } finally { db.SaveChanges(); } } }
public override void Up() { db db = new entity.db(); if (db.sales_packing.Count() > 0) { List <sales_packing> sales_packing = db.sales_packing.ToList(); db.sales_packing.RemoveRange(sales_packing); db.SaveChanges(); } AlterColumn("sales_packing_detail", "id_location", c => c.Int()); CreateIndex("sales_packing_detail", "id_location"); AddForeignKey("sales_packing_detail", "id_location", "app_location", "id_location"); }
private void btnSave_Click(object sender, RoutedEventArgs e) { try { if (!isExternalCall) { IEnumerable <DbEntityValidationResult> validationresult = _entity.db.GetValidationErrors(); if (validationresult.Count() == 0) { _entity.db.SaveChanges(); btnCancel_MouseDown(sender, e); } } else { IEnumerable <DbEntityValidationResult> validationresult = db.GetValidationErrors(); if (validationresult.Count() == 0) { if (operationMode == Class.clsCommon.Mode.Add) { db.SaveChanges(); entity.item_brand item_brand = myViewSource.View.CurrentItem as entity.item_brand; //db.Entry(item_brand).State = EntityState.Detached; //_entity.db.item_brand.Attach(item_brand); item_brandViewSource.View.Refresh(); item_brandViewSource.View.MoveCurrentTo(item_brand); MainViewSource.View.Refresh(); MainViewSource.View.MoveCurrentTo(curObject); btnCancel_MouseDown(sender, e); } else if (operationMode == Class.clsCommon.Mode.Edit) { btnCancel_MouseDown(sender, e); } } } } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); } }
private async void btnApprove_Click(object sender, MouseButtonEventArgs e) { try { string server = Cognitivo.Properties.Settings.Default.DebeHaberConnString + "/api/registration/54HY3kXgamBsJ94hhd1DYsFSWzlI4KtF7aJMDxO9D4wnTVaEoqtuI42eC1sM5NMqFvZsHhYPgsudolP8Ug1JhKPyBMKxfbvGSnON/" + Company_RUC; var json = await DownloadPage(server); string Hash = JsonConvert.DeserializeObject <DebeHaberRegistration>(json).hash_integretion; using (entity.db db = new entity.db()) { entity.app_company company = db.app_company.Where(x => x.id_company == entity.CurrentSession.Id_Company).FirstOrDefault(); company.hash_debehaber = Hash; db.SaveChanges(); } tabUpLoad.IsSelected = true; frameDebeHaberIntg.Refresh(); } catch (Exception ex) { MessageBox.Show("Connection Error: " + ex.Message); return; } }