private void BtnSave_Click(object sender, EventArgs e)
        {
            try
            {
                UserGridView.UpdateCurrentRow();
                UserGridView.CloseEditor();
                using (var con = new SqlConnection(ProjectFunctions.GetConnection()))
                {
                    con.Open();
                    var cmd = new SqlCommand
                    {
                        Connection = con
                    };
                    var Dt = (WorkAllocationGrid.DataSource as DataTable).GetChanges();

                    var MaxRow = Dt.Rows.Count;

                    for (var i = 0; i < MaxRow; i++)
                    {
                        var     currentrow = Dt.Rows[i];
                        DataSet ds         = ProjectFunctions.GetDataSet(" Select ProgCode From UserProgAccess Where UserName='******'And  ProgCode='" + currentrow["ProgCode"].ToString() + "'");
                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            cmd.CommandType = CommandType.StoredProcedure;
                            cmd.CommandText = "sp_UpdateUserWorkAllocation";
                        }
                        else
                        {
                            cmd.CommandType = CommandType.StoredProcedure;
                            cmd.CommandText = "sp_InsertUserWorkAllocation";
                        }
                        cmd.Parameters.Add("@dUserName", SqlDbType.VarChar).Value = cmbSelectUser.Text;
                        cmd.Parameters.Add("@dProgCode", SqlDbType.VarChar).Value = currentrow["ProgCode"];
                        if (currentrow["&Add"].ToString() == "True")
                        {
                            cmd.Parameters.Add("@dProgAdd_F", SqlDbType.SmallInt).Value = -1;
                        }
                        else
                        {
                            cmd.Parameters.Add("@dProgAdd_F", SqlDbType.SmallInt).Value = 0;
                        }
                        if (currentrow["SELECTFIELD"].ToString() == "True")
                        {
                            cmd.Parameters.Add("@dSelectField", SqlDbType.SmallInt).Value = -1;
                        }
                        else
                        {
                            cmd.Parameters.Add("@dSelectField", SqlDbType.SmallInt).Value = 0;
                        }
                        if (currentrow["EDIT"].ToString() == "True")
                        {
                            cmd.Parameters.Add("@dProgUpd_F", SqlDbType.SmallInt).Value = -1;
                        }
                        else
                        {
                            cmd.Parameters.Add("@dProgUpd_F", SqlDbType.SmallInt).Value = 0;
                        }
                        if (currentrow["DELETE"].ToString() == "True")
                        {
                            cmd.Parameters.Add("@dProgDel_F", SqlDbType.SmallInt).Value = -1;
                        }
                        else
                        {
                            cmd.Parameters.Add("@dProgDel_F", SqlDbType.SmallInt).Value = 0;
                        }

                        if (currentrow["TRANSACTION"].ToString() == "True")
                        {
                            cmd.Parameters.Add("@dTransactionsMenu", SqlDbType.SmallInt).Value = -1;
                        }
                        else
                        {
                            cmd.Parameters.Add("@dTransactionsMenu", SqlDbType.SmallInt).Value = 0;
                        }
                        if (currentrow["MASTER"].ToString() == "True")
                        {
                            cmd.Parameters.Add("@dMasterMenu", SqlDbType.SmallInt).Value = -1;
                        }
                        else
                        {
                            cmd.Parameters.Add("@dMasterMenu", SqlDbType.SmallInt).Value = 0;
                        }
                        if (currentrow["ADMIN"].ToString() == "True")
                        {
                            cmd.Parameters.Add("@dAdministratorMenu", SqlDbType.SmallInt).Value = -1;
                        }
                        else
                        {
                            cmd.Parameters.Add("@dAdministratorMenu", SqlDbType.SmallInt).Value = 0;
                        }
                        if (currentrow["REPORT"].ToString() == "True")
                        {
                            cmd.Parameters.Add("@dReportMenu", SqlDbType.SmallInt).Value = -1;
                        }
                        else
                        {
                            cmd.Parameters.Add("@dReportMenu", SqlDbType.SmallInt).Value = 0;
                        }
                        if (currentrow["SPLRIGHTS"].ToString() == "True")
                        {
                            cmd.Parameters.Add("@dProgSpl_U", SqlDbType.SmallInt).Value = -1;
                        }
                        else
                        {
                            cmd.Parameters.Add("@dProgSpl_U", SqlDbType.SmallInt).Value = 0;
                        }
                        cmd.ExecuteNonQuery();
                        cmd.Parameters.Clear();
                    }
                    WorkAllocationGrid.DataSource = null;
                }
            }
            catch (Exception ex)
            {
                ProjectFunctions.SpeakError(ex.Message);
            }
        }