private void btnOk_Click(object sender, EventArgs e) { DBLayer.Charges.Details det = new FitnessProject.DBLayer.Charges.Details(); //det.AdminstratorId = ((Lib.ServiceFunctions.ListItem)ddlAdministrators.SelectedItem).ID; det.Date = DateTime.Now.Date; det.GroupId = 3; string name = ""; if (!this.IsChanged) { name = ((Lib.ServiceFunctions.ListItem)ddlAdministrators.SelectedItem).Name; } else { name = ddlAdministrators.Text; } det.Name = "Аванс: " + name; det.Summ = Convert.ToDouble(tbSumm.Text); DBLayer.Charges.Insert(det); this.Close(); }
private void btnOk_Click(object sender, EventArgs e) { this.Details.SupplierId = ((Lib.ServiceFunctions.ListItem)cbSuppliers.SelectedItem).ID; this.Details.ProductId = ((Lib.ServiceFunctions.ListItem)cbProduct.SelectedItem).ID; this.Details.Date = Convert.ToDateTime(tbDate.Text); this.Details.Price = Convert.ToDouble(tbPrice.Text); this.Details.Quantity = Convert.ToDouble(tbQuantity.Text); if (this.Id == 0) { this.Details.Id = DBLayer.ArrivalDetails.Insert(this.Details); DBLayer.Charges.Details det = new FitnessProject.DBLayer.Charges.Details(); det.AdminstratorId = ((DBLayer.Users.Details)AppDomain.CurrentDomain.GetData("User")).Id; det.Date = DateTime.Now.Date; det.GroupId = 4; det.Name = "Закупка " + ((Lib.ServiceFunctions.ListItem)cbProduct.SelectedItem).Name; det.Summ = this.Details.Price * this.Details.Quantity; int id = DBLayer.Charges.Insert(det); this.Details.ChargeId = id; DBLayer.ArrivalDetails.Update(this.Details); } else { DBLayer.ArrivalDetails.Update(this.Details); if (this.Details.ChargeId != 0) { DBLayer.Charges.Details chDet = DBLayer.Charges.GetDetails(this.Details.ChargeId); chDet.Date = this.Details.Date; chDet.Summ = this.Details.Price * this.Details.Quantity; DBLayer.Charges.Update(chDet); } } this.Close(); }