예제 #1
0
        public List <SendMedicine> LoadMedicines(string center, string thana, string district)
        {
            int centerID   = aMedicineGateway.GetIDByCenterName(center);
            int thanaID    = aMedicineGateway.GetIDByThanaName(thana);
            int districtID = aMedicineGateway.GetIDByDistrictName(district);

            SqlConnection connection = new SqlConnection(connectionString);
            string        query      = "select * from tbl_SendMedicine where Center = '" + centerID + "' and ThanaID = '" + thanaID + "' and DistrictID = '" + districtID + "'";
            SqlCommand    command    = new SqlCommand(query, connection);

            connection.Open();
            List <SendMedicine> medicineList = new List <SendMedicine>();
            SqlDataReader       reader       = command.ExecuteReader();

            while (reader.Read())
            {
                SendMedicine aMedicine = new SendMedicine();
                aMedicine.ID       = int.Parse(reader["ID"].ToString());
                aMedicine.Medicine = reader["MedicineName"].ToString();
                medicineList.Add(aMedicine);
            }
            reader.Close();
            connection.Close();
            return(medicineList);
        }
예제 #2
0
        protected void saveButton_Click(object sender, EventArgs e)
        {
            int result = 0;

            foreach (MedicineQuantity medicineQuantity in medicineList)
            {
                SendMedicine aSendMedicine = new SendMedicine();

                string district = districtDropDownList.SelectedItem.ToString();
                aSendMedicine.DistrictID = aMedicineManager.GetIDByDistrictName(district);
                string thana = thanaDropDownList.SelectedItem.ToString();
                aSendMedicine.ThanaID = aMedicineManager.GetIDByThanaName(thana);
                string center = centerDropDownList.SelectedItem.ToString();
                aSendMedicine.CenterID = aMedicineManager.GetIDByCenterName(center);
                aSendMedicine.Medicine = medicineQuantity.Name;
                aSendMedicine.Quantity = int.Parse(medicineQuantity.Quantity.ToString());

                result = aMedicineManager.saveSendMedicine(aSendMedicine);
            }

            if (result != 0)
            {
                showLabel.Text = "Medicines added to center.";
            }
            else
            {
                showLabel.Text = "Medicines not added.";
            }
        }
        public int saveSendMedicine(SendMedicine aSendMedicine)
        {
            SqlConnection connection = new SqlConnection(connectionString);
            string        query      = "insert into tbl_SendMedicine values('" + aSendMedicine.DistrictID + "','" + aSendMedicine.ThanaID + "','" + aSendMedicine.CenterID + "','" + aSendMedicine.Medicine + "','" + aSendMedicine.Quantity + "')";
            SqlCommand    command    = new SqlCommand(query, connection);

            connection.Open();
            int rowAffected = command.ExecuteNonQuery();

            connection.Close();
            return(rowAffected);
        }
예제 #4
0
        public List <SendMedicine> MedicineList(int district, int thana, int center)
        {
            SqlConnection connection = new SqlConnection(connectionString);
            string        query      = "select MedicineName, Quantity from tbl_SendMedicine where DistrictID = '" + district + "' and ThanaID = '" + thana + "' and Center = '" + center + "'";
            SqlCommand    command    = new SqlCommand(query, connection);

            connection.Open();
            SqlDataReader       reader    = command.ExecuteReader();
            List <SendMedicine> medicines = new List <SendMedicine>();

            while (reader.Read())
            {
                SendMedicine aMedicine = new SendMedicine();
                aMedicine.Medicine = reader["MedicineName"].ToString();
                aMedicine.Quantity = int.Parse(reader["Quantity"].ToString());
                medicines.Add(aMedicine);
            }
            reader.Close();
            connection.Close();
            return(medicines);
        }
예제 #5
0
        public ActionResult SendMedicine(SendMedicine sendMedicine)
        {
            var districtList = headManager.GetDistrictList();

            ViewBag.DistrictList = new SelectList(districtList, "Id", "Name");

            var thanaList = headManager.GetThanaList();

            ViewBag.ThanaList = new SelectList(thanaList, "Id", "Name");

            var centerList = headManager.GetCenterList();

            ViewBag.CenterList = new SelectList(centerList, "Id", "Name");

            var medicineList = headManager.GetMedicineList();

            ViewBag.MedicineList = new SelectList(medicineList, "Id", "GenericName");

            List <SendMedicine> sendMedicines = (Session["SendMedicine"]) as List <SendMedicine>;

            ViewBag.SendMedicine = sendMedicines;

            if (!ModelState.IsValid)
            {
                return(View(sendMedicine));
            }

            sendMedicines.Add(sendMedicine);
            Session["SendMedicine"] = sendMedicines;

            foreach (SendMedicine medicine in sendMedicines)
            {
                medicine.MedicineName = headManager.GetMedicineNamebyId(medicine.MedicineId).GenericName;
            }

            ViewBag.SendMedicine = sendMedicines;
            ViewBag.Message      = "Medicine Added To the List";
            return(View(sendMedicine));
        }
 private void ShowInGridView()
 {
     sendMedicine = (SendMedicine)ViewState["SendMedicines"];
     showMedicineGridView.DataSource = SendMedicines;
     showMedicineGridView.DataBind();
 }
 protected void sendMedicineButton_Click(object sender, EventArgs e)
 {
     sendMedicine      = (SendMedicine)ViewState["SendMedicines"];
     messageLabel.Text = medicineManager.SaveAllSandMedicine(SendMedicines);
     ViewState.Clear();
 }
 public int saveSendMedicine(SendMedicine aSendMedicine)
 {
     return(aGateway.saveSendMedicine(aSendMedicine));
 }