public void AddMedicine(CenterMedicineRelation aCenterMedicineRelation)
        {
            string query = "update Center_Medicine_Relation_tbl set medicine_quantity = medicine_quantity + '" + aCenterMedicineRelation.MedicineQuantity + "'where center_Id= ' " + aCenterMedicineRelation.CenterId + "'and medicine_id = '" + aCenterMedicineRelation.MedicineId + "' ";
            SqlConnection aConnection = new SqlConnection(conncetionStr);
            SqlCommand aCommand = new SqlCommand(query, aConnection);

            aConnection.Open();
            int rowAffect = aCommand.ExecuteNonQuery();
            aConnection.Close();
        }
        public void Insert(CenterMedicineRelation aCenterMedicineRelation)
        {
            string query = "insert into Center_Medicine_Relation_tbl values ('" + aCenterMedicineRelation.CenterId + "','" + aCenterMedicineRelation.MedicineId + "','" + aCenterMedicineRelation.MedicineQuantity + "','" + aCenterMedicineRelation.Date + "')";
            SqlConnection aConnection = new SqlConnection(conncetionStr);
            SqlCommand aCommand = new SqlCommand(query, aConnection);

            aConnection.Open();
            int rowAffect = aCommand.ExecuteNonQuery();
            aConnection.Close();
        }
        public bool IsExist(CenterMedicineRelation aCenterMedicineRelation)
        {
            bool found = false;
            string query = "select * from Center_Medicine_Relation_tbl where center_id = '"+aCenterMedicineRelation.CenterId+"' and medicine_id = '"+aCenterMedicineRelation.MedicineId+"'";
            
            SqlConnection aConnection = new SqlConnection(conncetionStr);
            SqlCommand aCommand = new SqlCommand(query, aConnection);
            aConnection.Open();
            SqlDataReader aReader = aCommand.ExecuteReader();

            while (aReader.Read())
            {
                found = true;
            }
            aReader.Close();
            aConnection.Close();

            return found;
        }
        protected void saveButton_Click(object sender, EventArgs e)
        {
            DataTable dt = (DataTable)ViewState["MedicineList"];
            foreach (DataRow row in dt.Rows)
            {
                CenterMedicineRelation aCenterMedicineRelation = new CenterMedicineRelation();
                aCenterMedicineRelation.CenterId = centerManager.GetCenterId(centerDropDownList.Text, 0);
                aCenterMedicineRelation.MedicineId = aMedicineManager.GetMedicineIdByName(row["name"].ToString());
                aCenterMedicineRelation.MedicineQuantity = Convert.ToInt32(row["quantity"].ToString());
                aCenterMedicineRelation.Date = DateTime.Now.ToString();

                if (aCenterMedicineRelationManager.IsExist(aCenterMedicineRelation) == false)
                {
                    
                    aCenterMedicineRelationManager.Insert(aCenterMedicineRelation);
                }
                else
                {
                    aCenterMedicineRelationManager.AddMedicine(aCenterMedicineRelation);
                }
            }
            
        }
 public void AddMedicine(CenterMedicineRelation aCenterMedicineRelation)
 {
     aCenterMedicineRelationGetway.AddMedicine(aCenterMedicineRelation);
 }
 public bool IsExist(CenterMedicineRelation aCenterMedicineRelation)
 {
     return aCenterMedicineRelationGetway.IsExist(aCenterMedicineRelation);
 }
 public void UpdateMedicine(CenterMedicineRelation aCenterMedicineRelation)
 {
     aCenterMedicineRelationGetway.UpdateMedicine(aCenterMedicineRelation);
 }
 public void Insert(CenterMedicineRelation aCenterMedicineRelation)
 {
      aCenterMedicineRelationGetway.Insert(aCenterMedicineRelation);
 }
 protected void saveButton_Click(object sender, EventArgs e)
 {
     List<Treatment> aList = new List<Treatment>();
     aList = (List<Treatment>)ViewState["Treatment"];
     foreach (Treatment treatment in aList)
     {
         aTreatementManager.Insert(treatment);
         CenterMedicineRelation aCenterMedicineRelation = new CenterMedicineRelation();
         aCenterMedicineRelation.CenterId = Convert.ToInt32(Session["center_id"].ToString());
         aCenterMedicineRelation.MedicineId = treatment.MedicineId;
         aCenterMedicineRelation.MedicineQuantity = treatment.MedicineQty;
         aCenterMedicineRelationManager.UpdateMedicine(aCenterMedicineRelation);
     }
     massegeLabel.Text = "Saved";
 }