public MedicineModels GetByName(string Name) { try { var query = "SELECT * FROM tbl_Madecine WHERE Name='" + Name + "'"; var reader = _pharmaDb.ExecuteReader(query, _connectionString); if (reader.HasRows) { reader.Read(); var MedicineModel = new MedicineModels() { Category = reader["Category"].ToString(), Shalf = reader[""].ToString(), Name = reader["Name"].ToString(), BatchNo = reader[""].ToString(), BuyingPrice = Convert.ToInt32(reader["BuyingPrice"]), SellingPrice = Convert.ToInt32(reader["SellingPrice"]), Quantity = Convert.ToInt32(reader["Quantity"]) }; return(MedicineModel); } return(null); } catch (Exception e) { throw new Exception(e.Message); } }
public ActionResult Edit(MyClinic.Infrastructure.Medicine medicine) { Medicine originMedicine = medicineRepository.GetMedicineById(medicine.Id); try { if (medicine == null) { return(RedirectToAction("Error404", "Error")); } if (ModelState.IsValid) { var objSession = Session["user"] as MyClinic.Infrastructure.SessUser; medicine.CreatedBy = originMedicine.CreatedBy; medicine.CreatedDate = originMedicine.CreatedDate; string diffString = originMedicine.EnumeratePropertyDifferencesInString(medicine); medicineRepository.UpdateFieldChangedOnly(originMedicine, medicine); /*For Add New Record to LogTable*/ logTran.UserId = objSession.UserId; logTran.ProcessType = "Edit Medicine"; logTran.Description = "Edit Medicine value as follow: " + diffString; logTran.LogDate = DateTime.Now; logRepository.Add(logTran); return(RedirectToAction("Index", "Medicine")); } } catch (Exception ex) { log.Error(ex); ModelState.AddModelError("error", Translator.UnexpectedError); } IMedicineTypeRepository objMedicineType = new MedicineTypeRepository(); IMedicineUnitRepository objMedicineUnit = new MedicineUnitRepository(); IEnumerable <MedicineType> medicineTypeRecords = null; IEnumerable <MedicineUnit> unitRecords = null; try { medicineTypeRecords = objMedicineType.Get(); unitRecords = objMedicineUnit.Get(); } catch (Exception ex) { log.Error(ex); ModelState.AddModelError("error", Translator.UnexpectedError); } medicineModel = new MedicineModels { medicine = medicine, medicineTypeRecords = medicineTypeRecords, unitRecords = unitRecords }; return(View(medicineModel)); }
public ActionResult Add(MyClinic.Infrastructure.Medicine medicine) { IMedicineTypeRepository objMedicineType = new MedicineTypeRepository(); IMedicineUnitRepository objMedicineUnit = new MedicineUnitRepository(); IEnumerable <MedicineType> MedicineTypeRecords = null; IEnumerable <MedicineUnit> unitRecords = null; try { MedicineTypeRecords = objMedicineType.Get(); unitRecords = objMedicineUnit.Get(); } catch (Exception ex) { log.Error(ex); ModelState.AddModelError("error", Translator.UnexpectedError); } try { if (ModelState.IsValid) { var objSession = Session["user"] as MyClinic.Infrastructure.SessUser; medicine.CreatedBy = objSession.UserId; medicine.CreatedDate = DateTime.Now; medicineRepository.Add(medicine); /*For Add New Record to LogTable*/ logTran.UserId = objSession.UserId; logTran.ProcessType = "Add medicine"; logTran.Description = "Add New medicine Name :" + medicine.Name; logTran.LogDate = DateTime.Now; logRepository.Add(logTran); return(RedirectToAction("Index", "Medicine")); } else { medicineModel = new MedicineModels { medicine = medicine, medicineTypeRecords = MedicineTypeRecords, unitRecords = unitRecords }; } } catch (Exception ex) { log.Error(ex); ModelState.AddModelError("error", Translator.UnexpectedError); } return(View(medicineModel)); }
public bool MediSave(MedicineModels m) { try { var query = "INSERT INTO tbl_Madecine (Category,Shalf,Name, BatchNo,BuyingPrice,SellingPrice,Quantity) VALUES('" + m.Category + "','" + m.Shalf + "','" + m.Name + "','" + m.BatchNo + "','" + m.BuyingPrice + "','" + m.SellingPrice + "','" + m.Quantity + "')"; var rowAffected = _pharmaDb.ExecuteNonQuery(query, _connectionString); return(rowAffected > 0); } catch (Exception e) { throw new Exception(e.Message); } }
public bool Update(MedicineModels AMM) { try { var query = "UPDATE tbl_Add_Member SET Category='" + AMM.Category + "',Shalf='" + AMM.Shalf + "', Name='" + AMM.Name + "',BatchNo='" + AMM.BatchNo + "',BuyingPrice='" + AMM.BuyingPrice + "',SellingPrice='" + AMM.SellingPrice + "',Quantity='" + AMM.Quantity + "' where Name='" + AMM.Name + "' "; var rowAffected = _pharmaDb.ExecuteNonQuery(query, _connectionString); return(rowAffected > 0); } catch (Exception e) { throw new Exception(e.Message); } }
protected void btnAdd_Click(object sender, EventArgs e) { try { if (dropCategory.SelectedValue == "" || drop_Shalf.SelectedValue == "" || txtName.Text == "" || txtBatchNo.Text == "" || txtBatchNo.Text == "" || txtBuingPrice.Text == "" || txtSellingPrice.Text == "") { string validationMessage = "Please fillup Required fields"; lblMessage.Text = validationMessage; return; } var isUserExist = _medicineManager.IsUserNameExist(txtName.Text); if (isUserExist) { var validationMessage = "Roll Already Exist"; lblMessage.Text = validationMessage; return; } var MedicineModel = new MedicineModels(); MedicineModel.Category = dropCategory.SelectedValue; MedicineModel.Shalf = drop_Shalf.SelectedValue; MedicineModel.Name = txtName.Text; MedicineModel.BatchNo = txtBatchNo.Text; MedicineModel.BuyingPrice = Convert.ToInt32(txtBuingPrice.Text); MedicineModel.SellingPrice = Convert.ToInt32(txtSellingPrice.Text); MedicineModel.Quantity = Convert.ToInt32(txtQty.Text); var isSave = _medicineManager.CatSave(MedicineModel); if (isSave) { RefreshField(); string successMessage = " Saved Successfully"; lblMessage.Text = successMessage; lblMessage.ForeColor = Color.Green; return; } string failMessage = "Fild Not Saved "; lblMessage.Text = failMessage; } catch (Exception exception) { lblMessage.Text = exception.Message; } }
public ActionResult Edit(string id) { var intId = 0; int.TryParse(id, out intId); Medicine medicine = null; try { medicine = medicineRepository.GetMedicineById(intId); if (medicine == null) { return(RedirectToAction("Error404", "Error")); } } catch (Exception ex) { log.Error(ex); ModelState.AddModelError("error", Translator.UnexpectedError); } IMedicineTypeRepository objMedicineType = new MedicineTypeRepository(); IMedicineUnitRepository objMedicineUnit = new MedicineUnitRepository(); IEnumerable <MedicineType> medicineTypeRecords = null; IEnumerable <MedicineUnit> unitRecords = null; try { medicineTypeRecords = objMedicineType.Get(); unitRecords = objMedicineUnit.Get(); } catch (Exception ex) { log.Error(ex); ModelState.AddModelError("error", Translator.UnexpectedError); } medicineModel = new MedicineModels { medicine = medicine, medicineTypeRecords = medicineTypeRecords, unitRecords = unitRecords }; return(View(medicineModel)); }
public List <MedicineModels> GetAllItemsByCategories(int Id) { var _ItemsList = new List <MedicineModels>(); string query = ("Select *From Items Where CategoriesId='" + Id + "' "); var reader = _pharmaDb.Reader(query, _pharmaDb.ConnectionStrings()); if (reader.HasRows) { while (reader.Read()) { var _Items = new MedicineModels(); _Items.BatchNo = reader["BatchNo"].ToString(); _Items.Name = reader["Name"].ToString(); _ItemsList.Add(_Items); } } reader.Close(); return(_ItemsList); }
public ActionResult Ajindex(int?pageNo, int?pageSize, int?pageStatus, string orderBy, string order, string searchBy, string keyword) { try { var objSession = Session["user"] as MyClinic.Infrastructure.SessUser; string userType = objSession.UserType; MyClinic.Infrastructure.User user = new MyClinic.Infrastructure.User(); var _pageNo = pageNo ?? 1; var _pageSize = pageSize ?? Common.defaultPageSize; var _pageStatus = pageStatus ?? 1; orderBy = orderBy.Replace(" ", "") ?? Common.defaultOrderBy; order = order ?? Common.defaultListOrder; int totalRecords = 0; var medicines = medicineRepository.Search(searchBy, keyword, orderBy, order, _pageNo, _pageSize, out totalRecords); var listResult = Paging.GetResultInfo(totalRecords, _pageNo, _pageSize); var paging = Paging.GetPaging(totalRecords, _pageNo, _pageSize, _pageStatus, Common.defaultNoOfPageLinkList, "$common.pagingClick", orderBy, order); var itemPerPage = Paging.getItemPerPage(totalRecords, _pageSize, orderBy, order); PageUtilities pageUtilities = new PageUtilities() { listHeader = listResult, listFooter = paging + itemPerPage, order = order, orderBy = orderBy }; medicineModel = new MedicineModels { medicines = medicines, pageUtilities = pageUtilities, }; } catch (Exception ex) { log.Error(ex); ModelState.AddModelError("error", Translator.UnexpectedError); } return(View("Ajindex", "_LayoutBlank", medicineModel)); }
public ActionResult Index() { try { string searchBy = ""; string keyword = ""; var orderBy = Common.defaultOrderBy; var order = Common.defaultListOrder; var _pageNo = 1; var _pageSize = 10; var _pageStatus = 1; var totalRecords = 0; var medicines = medicineRepository.Search(searchBy, keyword, orderBy, order, _pageNo, _pageSize, out totalRecords); var listResult = Paging.GetResultInfo(totalRecords, _pageNo, _pageSize); var paging = Paging.GetPaging(totalRecords, _pageNo, _pageSize, _pageStatus, Common.defaultNoOfPageLinkList, "$common.pagingClick", orderBy, order); var itemPerPage = Paging.getItemPerPage(totalRecords, _pageSize, orderBy, order); PageUtilities pageUtilities = new PageUtilities() { listHeader = listResult, listFooter = paging + itemPerPage, order = order, orderBy = orderBy }; medicineModel = new MedicineModels { medicines = medicines, pageUtilities = pageUtilities, }; } catch (Exception ex) { log.Error(ex); ModelState.AddModelError("error", Translator.UnexpectedError); } return(View(medicineModel)); }
public ActionResult Detail(string id) { var intId = 0; int.TryParse(id, out intId); try { DTOMedicine dtomedicine = medicineRepository.GetDTOMedicineById(intId); if (dtomedicine == null) { return(RedirectToAction("Error404", "Error")); } medicineModel = new MedicineModels { dtomedicine = dtomedicine, }; } catch (Exception ex) { log.Error(ex); ModelState.AddModelError("error", Translator.UnexpectedError); } return(View(medicineModel)); }
public ActionResult Add() { IMedicineTypeRepository objMedicineType = new MedicineTypeRepository(); IMedicineUnitRepository objMedicineUnit = new MedicineUnitRepository(); IEnumerable <MedicineType> MedicineTypeRecords = null; IEnumerable <MedicineUnit> unitRecords = null; try { MedicineTypeRecords = objMedicineType.Get(); unitRecords = objMedicineUnit.Get(); } catch (Exception ex) { log.Error(ex); ModelState.AddModelError("error", Translator.UnexpectedError); } medicineModel = new MedicineModels { medicineTypeRecords = MedicineTypeRecords, unitRecords = unitRecords }; return(View(medicineModel)); }
public bool Update(MedicineModels AMM) { var update2 = _medicineRepository.Update(AMM); return(update2); }
public bool CatSave(MedicineModels m) { var save = _medicineRepository.MediSave(m); return(save); }