private Medicine FillToEntity() { Medicine medicine; if (IdMedicineEdit <= 0) { medicine = new Medicine(); //medicine.Id = 0; } else { medicine = medicineRepository.GetById(IdMedicineEdit); } medicine.Content = Convert.ToInt32(txtContent.Text.Trim()); medicine.Unit = Convert.ToInt32((txtUnit.Text.Trim())); medicine.ContentUnit = Convert.ToInt32(txtContentUnit.Text.Trim()); medicine.Description = txtDescription.Text.Trim(); // medicine.MedicineCode = txtMaThuoc.Text.Trim(); medicine.Name = txtTenThuoc.Text.Trim(); medicine.TradeName = txtTradeName.Text.Trim(); medicine.Type = rdARV.Checked; return(medicine); }
private void btnSynch_Click(object sender, System.EventArgs e) { if (this.Clinic == null || this.Clinic.Id == 0) { return; } var dialogResult = Medical.Forms.UI.MessageDialog.Instance.ShowMessage(this, "Q009", this.Clinic.Name); if (dialogResult == DialogResult.No) { return; } // Update tu server List <TableChange> lstServer = tableChangeServerRep.GetByClinicId(1); Medicine _clientEntiy; Medicine _serverEntity; if (lstServer.Count > 0) { foreach (TableChange ent in lstServer) { switch (ent.TableName.ToString()) { case "Medicine": _serverEntity = medicineServerRep.GetById(ent.Id); if (ent.Action.Equals("I")) { if ((Medicine)medicineRep.GetById(ent.Id) == null) { _clientEntiy = new Medicine(); _clientEntiy = medicineRep.CopyEntity(_clientEntiy, _serverEntity); medicineRep.Insert(_clientEntiy); } } if (ent.Action.Equals("U")) { if ((Medicine)medicineRep.GetById(ent.Id) != null) { _clientEntiy = medicineRep.GetById(ent.Id); _clientEntiy = medicineRep.CopyEntity(_serverEntity, _clientEntiy); medicineRep.Update(_clientEntiy); } } break; case "Clinic": break; } } } }
private void GrdCellEndEdit(object sender, System.Windows.Forms.DataGridViewCellEventArgs e) { try { if (e.ColumnIndex == 0 && this.grd[e.ColumnIndex, e.RowIndex].Value != null) { var warehouseIODetail = (WareHouseIODetail)this.bdsWareHouseIODetail.Current; var medicineId = (int)this.grd[e.ColumnIndex, e.RowIndex].Value; var medicine = _medicineRepository.GetById(medicineId); if (medicine == null) { grd.Rows[e.RowIndex].Cells[1].Value = ""; warehouseIODetail.Unit = 0; } else { grd.Rows[e.RowIndex].Cells[1].Value = medicine.TradeName; warehouseIODetail.Unit = medicine.Unit; } } /* * int volumn = 0; * int unitPrice = 0; * * if (grd.Columns[e.ColumnIndex].Name == "cboMedicine") * { * if (grd.Rows[e.RowIndex].Cells["cboMedicine"].Value != null) * { * var medicine = _medicineRepository.GetById(int.Parse(grd.Rows[e.RowIndex].Cells["cboMedicine"].Value.ToString())); * grd.Rows[e.RowIndex].Cells["MedicineId"].Value = medicine.Id; * grd.Rows[e.RowIndex].Cells["Unit"].Value = medicine.Define.Id; * grd.Rows[e.RowIndex].Cells["UnitName"].Value = medicine.Define.Name; * } * } */ if (grd.Columns[e.ColumnIndex].Name == "Qty" || grd.Columns[e.ColumnIndex].Name == "UnitPrice") { var volumn = 0; var unitPrice = 0; if (grd.Rows[e.RowIndex].Cells["Qty"].Value != null && int.TryParse(grd.Rows[e.RowIndex].Cells["Qty"].Value.ToString(), out volumn) && grd.Rows[e.RowIndex].Cells["UnitPrice"].Value != null && int.TryParse(grd.Rows[e.RowIndex].Cells["UnitPrice"].Value.ToString(), out unitPrice)) { grd.Rows[e.RowIndex].Cells["Amount"].Value = unitPrice * volumn; } } } catch (Exception ex) { MessageBox.Show(this, ex.Message); } }
private void grd_CellEndEdit(object sender, DataGridViewCellEventArgs e) { int volumn = 0; int unitPrice = 0; if (grd.Columns[e.ColumnIndex].Name == "MedicineId") { if (grd.Rows[e.RowIndex].Cells["MedicineId"].Value != null) { var medicine = repMedicine.GetById(int.Parse(grd.Rows[e.RowIndex].Cells["MedicineId"].Value.ToString())); grd.Rows[e.RowIndex].Cells["Unit"].Value = medicine.Define.Id; grd.Rows[e.RowIndex].Cells["UnitName"].Value = medicine.Define.Name; } } if (grd.Columns[e.ColumnIndex].Name == "Volumn" || grd.Columns[e.ColumnIndex].Name == "UnitPrice") { if (grd.Rows[e.RowIndex].Cells["Volumn"].Value != null && int.TryParse(grd.Rows[e.RowIndex].Cells["Volumn"].Value.ToString(), out volumn) && grd.Rows[e.RowIndex].Cells["UnitPrice"].Value != null && int.TryParse(grd.Rows[e.RowIndex].Cells["UnitPrice"].Value.ToString(), out unitPrice)) { grd.Rows[e.RowIndex].Cells["Amount"].Value = unitPrice * volumn; } } }
private void GrdCellEndEdit(object sender, DataGridViewCellEventArgs e) { var warehouseIoDetail = (WareHouseIODetail)this.bdsWarehouseIODetail.Current; switch (e.ColumnIndex) { case 0: // Get medicine if (warehouseIoDetail != null) { var medicine = _repMedicine.GetById(warehouseIoDetail.MedicineId); warehouseIoDetail.Unit = medicine.Unit; var warehouse = _repwh.GetByIdMedicine(medicine.Id, AppContext.CurrentClinic.Id); warehouseIoDetail.TotalQty = (warehouse == null ? 0 : warehouse.Volumn); warehouseIoDetail.LotNo = String.Empty; warehouseIoDetail.InStockQty = 0; warehouseIoDetail.Qty = 0; } break; case 4: if (warehouseIoDetail != null) { // lotNo var vwarehouseDetail = _vwarehouseDetailRep.Get(warehouseIoDetail.MedicineId, AppContext.CurrentClinic.Id, warehouseIoDetail.LotNo); warehouseIoDetail.InStockQty = vwarehouseDetail == null ? 0 : vwarehouseDetail.Qty; if (vwarehouseDetail != null) { warehouseIoDetail.ExpireDate = vwarehouseDetail.ExpiredDate; } warehouseIoDetail.Qty = 0; } break; case 7: break; } /* * if (grd.Columns[e.ColumnIndex].Name == "cboMedicine") * { * if (grd.Rows[e.RowIndex].Cells["cboMedicine"].Value != null) * { * if (ValidateRowData(grd.Rows[e.RowIndex].Cells["cboMedicine"].Value.ToString())) * { * var warehouseItem = repwh.GetByIdMedicine(int.Parse(grd.Rows[e.RowIndex].Cells["cboMedicine"].Value.ToString()), AppContext.CurrentClinic.Id); * grd.Rows[e.RowIndex].Cells["Volumn"].Value = warehouseItem.Volumn; * grd.Rows[e.RowIndex].Cells["MinAllowed"].Value = warehouseItem.MinAllowed; * grd.Rows[e.RowIndex].Cells["MedicineId"].Value = warehouseItem.MedicineId; * grd.Rows[e.RowIndex].Cells["Id"].Value = warehouseItem.Id; * grd.Rows[e.RowIndex].Cells["ClinicId"].Value = warehouseItem.ClinicId; * grd.Rows[e.RowIndex].Cells["Export"].ReadOnly = false; * } * else * { * MessageBox.Show("Loại thuốc này đã tồn tại trong danh sách xuất kho"); * grd.Rows[e.RowIndex].Cells["Export"].ReadOnly = true; * } * } * } * else if (grd.Columns[e.ColumnIndex].Name == "Export") * { * int export = 0; * if (grd.Rows[e.RowIndex].Cells["Export"].Value != null && !int.TryParse(grd.Rows[e.RowIndex].Cells["Export"].Value.ToString(), out export)) * { * grd.Rows[e.RowIndex].Cells["Export"].Value = 0; * } * else if (export > int.Parse(grd.Rows[e.RowIndex].Cells["Volumn"].Value.ToString())) * { * grd.Rows[e.RowIndex].Cells["Export"].Value = grd.Rows[e.RowIndex].Cells["Volumn"].Value; * } * } */ this.grd.ResetBindings(); this.grd.Refresh(); }