Esempio n. 1
0
 private void btnAddNewLoaction_Click(object sender, EventArgs e)
 {
     string LocationName = txtLoactionName.Text;
     string LocationAddress = txtLocationAddress.Text;
     LocationManager ls = new LocationManager(LocationName,LocationAddress);
     if (!string.IsNullOrEmpty(LocationName))
     {
         bool res = ls.AddLocation(ls);
         if (res)
         {
             MessageBox.Show("Record Inserted Succesfully.!");
             bindLocation();
             pnlLocationGrid.Visible = true;
             pnlLocationForm.Visible = false;
         }
         else
         {
             MessageBox.Show("Error.!");
         }
     }
     else
     {
         MessageBox.Show("Enter Location Name");
     }
 }
Esempio n. 2
0
 public void UpdateLocation(LocationManager location)
 {
     SqlParameter[] sp = new SqlParameter[3];
     sp[0] = new SqlParameter("@LocationID", location.LocationID);
     sp[1] = new SqlParameter("@LocationName", location.LocationName);
     sp[2] = new SqlParameter("@LocationAddress", location.LocationAddress);
     datalayer.Execute_NonQuery("sp_UpdateLocation", CommandType.StoredProcedure, sp);
 }
Esempio n. 3
0
 public bool AddLocation(LocationManager newLocation)
 {
     SqlParameter[] sp = new SqlParameter[4];
     sp[0] = new SqlParameter("@LocationName",newLocation.LocationName);
     sp[1] = new SqlParameter("@LocationAddress",newLocation.LocationAddress);
     sp[2] = new SqlParameter("@CreatedDate", DateTime.Now);
     sp[3] = new SqlParameter("@IsDeleted", false);
     return datalayer.Execute_NonQuery("sp_AddNewLocation", CommandType.StoredProcedure, sp);
 }
Esempio n. 4
0
        public void bindLocation()
        {
            LocationManager ls = new LocationManager();
            DataSet ds = ls.ListLocations();
            if (ds.Tables[0].Rows.Count > 0)
            {
                LocationGrid.AutoGenerateColumns = false;
                LocationGrid.DataSource = null;
                //Set Columns Count
                LocationGrid.ColumnCount = 3;

                //Add Columns
                LocationGrid.Columns[0].Name = "Id";
                LocationGrid.Columns[0].HeaderText = "Id";
                LocationGrid.Columns[0].DataPropertyName = "id";

                LocationGrid.Columns[1].HeaderText = "Location Name";
                LocationGrid.Columns[1].Name = "LocationName";
                LocationGrid.Columns[1].DataPropertyName = "LocationName";

                LocationGrid.Columns[2].Name = "Address";
                LocationGrid.Columns[2].HeaderText = "Location Address";
                LocationGrid.Columns[2].DataPropertyName = "LocationAddress";

                LocationGrid.DataSource = ds.Tables[0];

                //Buttons

                DataGridViewLinkColumn Editlink = new DataGridViewLinkColumn();
                Editlink.UseColumnTextForLinkValue = true;
                Editlink.HeaderText = "Edit";
                Editlink.DataPropertyName = "lnkForEditColumn";
                Editlink.LinkBehavior = LinkBehavior.SystemDefault;
                Editlink.Text = "Edit";
                LocationGrid.Columns.Add(Editlink);

                DataGridViewLinkColumn Deletelink = new DataGridViewLinkColumn();
                Deletelink.UseColumnTextForLinkValue = true;
                Deletelink.HeaderText = "delete";
                Deletelink.DataPropertyName = "lnkForDeleteColumn";
                Deletelink.LinkBehavior = LinkBehavior.SystemDefault;
                Deletelink.Text = "Delete";
                LocationGrid.Columns.Add(Deletelink);

                //DataGridViewButtonColumn db = new DataGridViewButtonColumn();
                //db.Text = "Delete";
                //LocationGrid.Columns.Insert(3, (DataGridViewColumn)db);
            }
        }
Esempio n. 5
0
        private void LocationGrid_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            int location_id = 0;

            if (e.ColumnIndex == 3)
            {

                txtLoactionName.Text = LocationGrid.Rows[e.RowIndex].Cells["LocationName"].Value.ToString();
                txtLocationAddress.Text = LocationGrid.Rows[e.RowIndex].Cells["Address"].Value.ToString();
                lblLocationID.Text = LocationGrid.Rows[e.RowIndex].Cells["Id"].Value.ToString();

                pnlLocationForm.Visible = true;
                pnlLocationGrid.Visible = false;
                btnAddNewLoaction.Visible = false;

            }
            if (e.ColumnIndex == 4)
            {
                location_id = Convert.ToInt32(LocationGrid.Rows[e.RowIndex].Cells["Id"].Value);

                LocationManager loc_manager = new LocationManager();
                loc_manager.DeleteLocation(location_id);
                bindLocation();

                pnlLocationForm.Visible = false;
                pnlLocationGrid.Visible = true;
            }
        }
Esempio n. 6
0
 private void btnUpdate_Click(object sender, EventArgs e)
 {
     int LocationID = Convert.ToInt32(lblLocationID.Text);
     string LocationName = txtLoactionName.Text;
     string LocationAddress = txtLocationAddress.Text;
     LocationManager ls = new LocationManager(LocationID,LocationName, LocationAddress);
     if (!string.IsNullOrEmpty(LocationName))
     {
         try
         {
             ls.UpdateLocation(ls);
             MessageBox.Show("Location Updated Succesfully.!");
             bindLocation();
             pnlLocationGrid.Visible = true;
             pnlLocationForm.Visible = false;
         }
         catch(Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
     else
     {
         MessageBox.Show("Enter Location Name");
     }
 }
Esempio n. 7
0
        public void bindLocationDropDown()
        {
            LocationManager ls = new LocationManager();
            DataSet ds = ls.ListLocations();
            if (ds.Tables[0].Rows.Count > 0)
            {

                drpLocationList.DisplayMember = "LocationName";
                drpLocationList.ValueMember = "id";
                drpLocationList.DataSource = ds.Tables[0];
            }
            else
            {
                //drpLocation.Items.Add()
            }
        }